home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / tads2exe.zip / ADV.T next >
Text File  |  1992-11-17  |  103KB  |  3,574 lines

  1. /* $Header$ */
  2. /* Copyright (c) 1988, 1991 by Michael J. Roberts.  All Rights Reserved. */
  3. /*
  4.    adv.t  - standard adventure definitions for TADS games
  5.    Version 2.0
  6.  
  7.    This file is part of TADS:  The Text Adventure Development System.
  8.    Please see the file LICENSE.DOC (which should be part of the TADS
  9.    distribution) for information on using this file, and for information
  10.    on reaching High Energy Software, the developers of TADS.
  11.  
  12.    This file defines the basic classes and functions used by most TADS
  13.    adventure games.  It is generally #include'd at the start of each game
  14.    source file.
  15. */
  16.  
  17. /*
  18.  *   Define compound prepositions.  Since prepositions that appear in
  19.  *   parsed sentences must be single words, we must define any logical
  20.  *   prepositions that consist of two or more words here.  Note that
  21.  *   only two words can be pasted together at once; to paste more, use
  22.  *   a second step.  For example,  'out from under' must be defined in
  23.  *   two steps:
  24.  *
  25.  *     compoundWord 'out' 'from' 'outfrom';
  26.  *     compoundWord 'outfrom' 'under' 'outfromunder';
  27.  *
  28.  *   Listed below are the compound prepositions that were built in to
  29.  *   version 1.0 of the TADS run-time.
  30.  */
  31. compoundWord 'on' 'to' 'onto';           /* on to --> onto */
  32. compoundWord 'in' 'to' 'into';           /* in to --> into */
  33. compoundWord 'in' 'between' 'inbetween'; /* and so forth */
  34. compoundWord 'down' 'in' 'downin';
  35. compoundWord 'down' 'on' 'downon';
  36. compoundWord 'up' 'on' 'upon';
  37. compoundWord 'out' 'of' 'outof';
  38. compoundWord 'off' 'of' 'offof';
  39.  
  40. /*
  41.  *   Format strings:  these associate keywords with properties.  When
  42.  *   a keyword appears in output between percent signs (%), the matching
  43.  *   property of the current command's actor is evaluated and substituted
  44.  *   for the keyword (and the percent signs).  For example, if you have:
  45.  *
  46.  *      formatstring 'you' fmtYou;
  47.  *
  48.  *   and the command being processed is:
  49.  *
  50.  *      fred, pick up the paper
  51.  *
  52.  *   and the "fred" actor has fmtYou = "he", and this string is output:
  53.  *
  54.  *      "%You% can't see that here."
  55.  *
  56.  *   Then the actual output is:  "He can't see that here."
  57.  *
  58.  *   The format strings are chosen to look like normal output (minus the
  59.  *   percent signs, of course) when the actor is Me.
  60.  */
  61. formatstring 'you' fmtYou;
  62. formatstring 'your' fmtYour;
  63. formatstring 'you\'re' fmtYoure;
  64. formatstring 'youm' fmtYoum;
  65. formatstring 'you\'ve' fmtYouve;
  66. formatstring 's' fmtS;
  67. formatstring 'es' fmtEs;
  68. formatstring 'have' fmtHave;
  69. formatstring 'do' fmtDo;
  70. formatstring 'are' fmtAre;
  71.  
  72. /*
  73.  *   Special Word List: This list defines the special words that the
  74.  *   parser needs for input commands.  If the list is not provided, the
  75.  *   parser uses the old defaults.  The list below is the same as the old
  76.  *   defaults.  Note - the words in this list must appear in the order
  77.  *   shown below.
  78.  */
  79. specialWords
  80.    'of',                        /* used in phrases such as "piece of paper" */
  81.    'and',             /* conjunction for noun lists or to separate commands */
  82.    'then',                              /* conjunction to separate commands */
  83.    'all' = 'everything',               /* refers to every accessible object */
  84.    'both',      /* used with plurals, or to answer disambiguation questions */
  85.    'but' = 'except',                      /* used to exclude items from ALL */
  86.    'one',                       /* used to answer questions:  "the red one" */
  87.    'ones',                        /* likewise for plurals:  "the blue ones" */
  88.    'it',                        /* refers to last single direct object used */
  89.    'them',                             /* refers to last direct object list */
  90.    'him',                       /* refers to last masculine actor mentioned */
  91.    'her'                         /* refers to last feminine actor mentioned */
  92. ;
  93.   
  94.  
  95. /*
  96.  *   Forward-declare functions.  This is not required in most cases,
  97.  *   but it doesn't hurt.  Providing these forward declarations ensures
  98.  *   that the compiler knows that we want these symbols to refer to
  99.  *   functions rather than objects.
  100.  */
  101. checkDoor: function;
  102. checkReach: function;
  103. itemcnt: function;
  104. listcont: function;
  105. listcontcont: function;
  106. turncount: function;
  107. addweight: function;
  108. addbulk: function;
  109. incscore: function;
  110. darkTravel: function;
  111. scoreRank: function;
  112. terminate: function;
  113. goToSleep: function;
  114. initSearch: function;
  115.  
  116. /*
  117.  *   checkDoor:  if the door d is open, this function silently returns
  118.  *   the room r.  Otherwise, print a message ("The door is closed.") and
  119.  *   return nil.
  120.  */
  121. checkDoor: function( d, r )
  122. {
  123.     if ( d.isopen ) return( r );
  124.     else
  125.     {
  126.         setit( d );
  127.     caps(); d.thedesc; " is closed. ";
  128.     return( nil );
  129.     }
  130. }
  131.  
  132. /*
  133.  *   checkReach:  determines whether the object obj can be reached by
  134.  *   actor in location loc, using the verb v.  This routine returns true
  135.  *   if obj is a special object (numObj or strObj), if obj is in actor's
  136.  *   inventory or actor's location, or if it's in the 'reachable' list
  137.  *   for loc.
  138.  */
  139. checkReach: function( loc, actor, v, obj )
  140. {
  141.     if ( obj=numObj or obj=strObj ) return;
  142.     if ( not ( actor.isCarrying( obj ) or obj.isIn( actor.location )))
  143.     {
  144.         if (find( loc.reachable, obj ) <> nil ) return;
  145.         "%You% can't reach "; obj.thedesc; " from "; loc.thedesc; ". ";
  146.         exit;
  147.     }
  148. }
  149.  
  150. /*
  151.  *  itemcnt: function( list )
  152.  *
  153.  *  Returns a count of the "listable" objects in list.  An
  154.  *  object is listable (that is, it shows up in a room's description)
  155.  *  if its isListed property is true.  This function is
  156.  *  useful for determining how many objects (if any) will be listed
  157.  *  in a room's description.
  158. */
  159. itemcnt: function( list )
  160. {
  161.     local cnt, tot, i;
  162.     tot := length( list );
  163.     cnt := 0;
  164.     i := 1;
  165.     while ( i <= tot )
  166.     {
  167.         if ( list[i].isListed ) cnt := cnt+1;
  168.         i := i+1;
  169.     }
  170.     return( cnt );
  171. }
  172.  
  173. /*
  174.  *  listcont: function( obj )
  175.  *
  176.  *  This function displays the contents of an object, separated by
  177.  *  commas.  The thedesc properties of the contents are used.
  178.  *  It is up to the caller to provide the introduction to the list
  179.  *  (usually something to the effect of "The box contains" is
  180.  *  displayed before calling listcont) and finishing the
  181.  *  sentence (usually by displaying a period).  An object is listed
  182.  *  only if its isListed property is true.
  183. */
  184. listcont: function( obj )
  185. {
  186.     local i, count, tot, list, cur, disptot;
  187.     count := 0;
  188.     list := obj.contents;
  189.     tot := length( list );
  190.     disptot := itemcnt( list );
  191.     i := 1;
  192.     while ( i <= tot )
  193.     {
  194.         cur := list[i];
  195.         if ( cur.isListed )
  196.         {
  197.             if ( count > 0 )
  198.             {
  199.                 if ( count+1 < disptot )
  200.                     ", ";
  201.                 else if (count = 1)
  202.                     " and ";
  203.                 else
  204.                     ", and ";
  205.             }
  206.             count := count + 1;
  207.             cur.adesc;               // list this object
  208.             if ( cur.isworn ) " (being worn)";
  209.             if ( cur.islamp and cur.islit ) " (providing light)";
  210.         }
  211.         i := i + 1;
  212.     }
  213. }
  214.  
  215. /*
  216.  *   showcontcont:  list the contents of the object, plus the contents of
  217.  *   an fixeditem's contained by the object.  A complete sentence is shown.
  218.  *   This is an internal routine used by listcontcont and listfixedcontcont.
  219.  */
  220. showcontcont: function( obj )
  221. {
  222.     if (itemcnt( obj.contents ))
  223.     {
  224.         if ( obj.issurface and not obj.isqsurface )
  225.         {
  226.             "Sitting on "; obj.thedesc;" is "; listcont( obj );
  227.             ". ";
  228.         }
  229.         else if ( obj.contentsVisible and not obj.isqcontainer )
  230.         {
  231.             caps();
  232.             obj.thedesc; " seems to contain ";
  233.             listcont( obj );
  234.             ". ";
  235.         }
  236.     }
  237.     if ( obj.contentsVisible and not obj.isqcontainer )
  238.         listfixedcontcont( obj );
  239. }
  240.  
  241. /*
  242.  *  listfixedcontcont: function( obj )
  243.  *
  244.  *  List the contents of the contents of any fixeditem objects
  245.  *  in the contents list of the object obj.  This routine
  246.  *  makes sure that all objects that can be taken are listed somewhere
  247.  *  in a room's description.  This routine recurses down the contents
  248.  *  tree, following each branch until either something has been listed
  249.  *  or the branch ends without anything being listable.  This routine
  250.  *  displays a complete sentence, so no introductory or closing text
  251.  *  is needed.
  252. */
  253. listfixedcontcont: function( obj )
  254. {
  255.     local list, i, tot, thisobj;
  256.  
  257.     list := obj.contents;
  258.     tot := length( list );
  259.     i := 1;
  260.     while ( i <= tot )
  261.     {
  262.         thisobj := list[i];
  263.         if ( thisobj.isfixed and thisobj.contentsVisible and
  264.       not thisobj.isqcontainer )
  265.             showcontcont( thisobj );
  266.     i := i + 1;
  267.     }
  268. }
  269.  
  270. /*
  271.  *  listcontcont: function( obj )
  272.  *
  273.  *  This function lists the contents of the contents of an object.
  274.  *  It displays full sentences, so no introductory or closing text
  275.  *  is required.  Any item in the contents list of the object
  276.  *  obj whose contentsVisible property is true has
  277.  *  its contents listed.  An Object whose isqcontainer or
  278.  *  isqsurface property is true will not have its
  279.  *  contents listed.
  280. */
  281. listcontcont: function( obj )
  282. {
  283.     local list, i, tot;
  284.     list := obj.contents;
  285.     tot := length( list );
  286.     i := 1;
  287.     while ( i <= tot )
  288.     {
  289.         showcontcont( list[i] );
  290.     i := i + 1;
  291.     }
  292. }
  293.  
  294. /*
  295.  *  turncount: function( parm )
  296.  *
  297.  *  This function can be used as a daemon (normally set up in the init
  298.  *  function) to update the turn counter after each turn.  This routine
  299.  *  increments global.turnsofar, and then calls setscore to
  300.  *  update the status line with the new turn count.
  301. */
  302. turncount: function( parm )
  303. {
  304.     incturn();
  305.     global.turnsofar := global.turnsofar + 1;
  306.     setscore( global.score, global.turnsofar );
  307. }
  308.  
  309. /*
  310.  *  addweight: function( list )
  311.  *
  312.  *  Adds the weights of the objects in list and returns the sum.
  313.  *  The weight of an object is given by its weight property.  This
  314.  *  routine includes the weights of all of the contents of each object,
  315.  *  and the weights of their contents, and so forth.
  316. */
  317. addweight: function( l )
  318. {
  319.     local tot, i, c, totweight;
  320.  
  321.     tot := length( l );
  322.     i := 1;
  323.     totweight := 0;
  324.     while ( i <= tot )
  325.     {
  326.         c := l[i];
  327.         totweight := totweight + c.weight;
  328.         if (length( c.contents ))
  329.             totweight := totweight + addweight( c.contents );
  330.         i := i + 1;
  331.     }
  332.     return( totweight );
  333. }
  334.  
  335. /*
  336.  *  addbulk: function( list )
  337.  *
  338.  *  This function returns the sum of the bulks (given by the bulk
  339.  *  property) of each object in list.  The value returned includes
  340.  *  only the bulk of each object in the list, and not of the contents
  341.  *  of the objects, as it is assumed that an object does not change in
  342.  *  size when something is put inside it.  You can easily change this
  343.  *  assumption for special objects (such as a bag that stretches as
  344.  *  things are put inside) by writing an appropriate bulk method
  345.  *  for that object.
  346. */
  347. addbulk: function( list )
  348. {
  349.     local i, tot, totbulk, rem, cur;
  350.  
  351.     tot := length( list );
  352.     i := 1;
  353.     totbulk := 0;
  354.     while( i <= tot )
  355.     {
  356.         cur := list[i];
  357.         if ( not cur.isworn )
  358.             totbulk := totbulk + cur.bulk;
  359.         i := i + 1;
  360.     }
  361.     return( totbulk );
  362. }
  363.  
  364. /*
  365.  *  incscore: function( amount )
  366.  *
  367.  *  Adds amount to the total score, and updates the status line
  368.  *  to reflect the new score.  The total score is kept in global.score.
  369.  *  Always use this routine rather than changing global.score
  370.  *  directly, since this routine ensures that the status line is
  371.  *  updated with the new value.
  372. */
  373. incscore: function( amount )
  374. {
  375.     global.score := global.score + amount;
  376.     setscore( global.score, global.turnsofar );
  377. }
  378.  
  379. /*
  380.  *  initSearch: function
  381.  *
  382.  *  Initializes the containers of objects with a searchLoc, underLoc,
  383.  *  and behindLoc by setting up searchCont, underCont, and
  384.  *  behindCont lists, respectively.  You should call this function once in
  385.  *  your preinit (or init, if you prefer) function to ensure that
  386.  *  the underable, behindable, and searchable objects are set up correctly.
  387. */
  388. initSearch: function
  389. {
  390.     local o;
  391.     
  392.     o := firstobj(hiddenItem);
  393.     while (o <> nil)
  394.     {
  395.     if (o.searchLoc)
  396.         o.searchLoc.searchCont := o.searchLoc.searchCont + o;
  397.     else if (o.underLoc)
  398.         o.underLoc.underCont := o.underLoc.underCont + o;
  399.     else if (o.behindLoc)
  400.         o.behindLoc.behindCont := o.behindLoc.behindCont + o;
  401.     o := nextobj(o, hiddenItem);
  402.     }
  403. }
  404.  
  405. /*
  406.  *  nestedroom: room
  407.  *
  408.  *  A special kind of room that is inside another room; chairs and
  409.  *  some types of vehicles, such as inflatable rafts, fall into this
  410.  *  category.  Note that a room can be within another room without
  411.  *  being a nestedroom, simply by setting its location property
  412.  *  to another room.  The nestedroom is different from an ordinary
  413.  *  room, though, in that it's an "open" room; that is, when inside it,
  414.  *  the actor is still really inside the enclosing room for purposes of
  415.  *  descriptions.  Hence, the player sees "Laboratory, in the chair."
  416.  *  In addition, a nestedroom is an object in its own right,
  417.  *  visible to the player; for example, a chair is an object in a
  418.  *  room in addition to being a room itself.
  419. */
  420. class nestedroom: room
  421.     islit =
  422.     {
  423.         if ( self.location ) return( self.location.islit );
  424.         return( nil );
  425.     }
  426.     statusLine =
  427.     {
  428.         self.location.sdesc; ", in "; self.thedesc; "\n\t";
  429.     }
  430.     lookAround( verbosity ) =
  431.     {
  432.         self.statusLine;
  433.     self.location.nrmLkAround( verbosity );
  434.     }
  435.     roomDrop( obj ) =
  436.     {
  437.         if ( self.location = nil or self.isdroploc ) pass roomDrop;
  438.     else self.location.roomDrop( obj );
  439.     }
  440. ;
  441.  
  442. /*
  443.  *  chairitem: fixeditem, nestedroom, surface
  444.  *
  445.  *  Acts like a chair:  actors can sit on the object.  While sitting
  446.  *  on the object, an actor can't go anywhere until standing up, and
  447.  *  can only reach objects that are on the chair and in the chair's
  448.  *  reachable list.  By default, nothing is in the reachable
  449.  *  list.  Note that there is no real distinction made between chairs
  450.  *  and beds, so you can sit or lie on either; the only difference is
  451.  *  the message displayed describing the situation.
  452. */
  453. class chairitem: fixeditem, nestedroom, surface
  454.     reachable = []          // list of all containers reachable from here;
  455.                             //  normally, you can only reach carried items
  456.                             //  from a chair, but this makes special allowances
  457.     ischair = true          // it is a chair by default; for beds or other
  458.                             //  things you lie down on, make it false
  459.     roomAction( actor, v, dobj, prep, io ) =
  460.     {
  461.         if ( dobj<>nil and v<>inspectVerb )
  462.             checkReach( self, actor, v, dobj );
  463.         if ( io<>nil and v<>askVerb and v<>tellVerb )
  464.             checkReach( self, actor, v, io );
  465.     pass roomAction;
  466.     }
  467.     enterRoom( actor ) = {}
  468.     noexit =
  469.     {
  470.         "%You're% not going anywhere until %you% get%s% out of ";
  471.     self.thedesc; ". ";
  472.         return( nil );
  473.     }
  474.     verDoBoard( actor ) = { self.verDoSiton( actor ); }
  475.     doBoard( actor ) = { self.doSiton( actor ); }
  476.     verDoSiton( actor ) =
  477.     {
  478.         if ( actor.location = self )
  479.         {
  480.             "%You're% already on "; self.thedesc; "! ";
  481.         }
  482.     }
  483.     doSiton( actor ) =
  484.     {
  485.         "Okay, %you're% now sitting on "; self.thedesc; ". ";
  486.         actor.travelTo( self );
  487.     }
  488.     verDoLieon( actor ) =
  489.     {
  490.         self.verDoSiton( actor );
  491.     }
  492.     doLieon( actor ) =
  493.     {
  494.         self.doSiton( actor );
  495.     }
  496. ;
  497.  
  498. /*
  499.  *  beditem: chairitem
  500.  *
  501.  *  This object is the same as a chairitem, except that the player
  502.  *  is described as lying on, rather than sitting in, the object.
  503. */
  504. class beditem: chairitem
  505.     ischair = nil
  506.     isbed = true
  507.     sdesc = "bed"
  508. ;
  509.  
  510. /*
  511.  *  thing: object
  512.  *
  513.  *  The basic class for objects in a game.  The property contents
  514.  *  is a list that specifies what is in the object; this property is
  515.  *  automatically set up by the system after the game is compiled to
  516.  *  contain a list of all objects that have this object as their
  517.  *  location property.  The contents property is kept
  518.  *  consistent with the location properties of referenced objects
  519.  *  by the moveInto method; always use moveInto rather than
  520.  *  directly setting a location property for this reason.  The
  521.  *  adesc method displays the name of the object with an indefinite
  522.  *  article; the default is to display "a" followed by the sdesc,
  523.  *  but objects that need a different indefinite article (such as "an"
  524.  *  or "some") should override this method.  Likewise, thedesc
  525.  *  displays the name with a definite article; by default, thedesc
  526.  *  displays "the" followed by the object's sdesc.  The sdesc
  527.  *  simply displays the object's name ("short description") without
  528.  *  any articles.  The ldesc is the long description, normally
  529.  *  displayed when the object is examined by the player; by default,
  530.  *  the ldesc displays "It looks like an ordinary sdesc."
  531.  *  The isIn(object) method returns true if the
  532.  *  object's location is the specified object or the object's
  533.  *  location is an object whose contentsVisible property is
  534.  *  true and that object's isIn(object) method is
  535.  *  true.  Note that if isIn is true, it doesn't
  536.  *  necessarily mean the object is reachable, because isIn is
  537.  *  true if the object is merely visible within the location.
  538.  *  The thrudesc method displays a message for when the
  539.  *  player looks through the object (objects such as windows would
  540.  *  use this property).  The moveInto(object) method
  541.  *  moves the object to be inside the specified object.
  542.  *  To make an object disappear, move it into nil.
  543. */
  544. class thing: object
  545.     isListed = true         // shows up in room/inventory listings
  546.     contents = []           // set up automatically by system - do not set
  547.     verGrab( obj ) = {}
  548.     Grab( obj ) = {}
  549.     adesc =
  550.     {
  551.         "a "; self.sdesc;   // default is "a <name>"; "self" is current object
  552.     }
  553.     thedesc =
  554.     {
  555.         "the "; self.sdesc; // default is "the <name>"
  556.     }
  557.     ldesc = { "It looks like an ordinary "; self.sdesc; " to me."; }
  558.     readdesc = { "%You% can't read "; self.adesc; ". "; }
  559.     actorAction( v, d, p, i ) =
  560.     {
  561.         "You have lost your mind. ";
  562.         exit;
  563.     }
  564.     contentsVisible = { return( true ); }
  565.     contentsReachable = { return( true ); }
  566.     isIn( obj ) =
  567.     {
  568.         local myloc;
  569.  
  570.         myloc := self.location;
  571.         if ( myloc )
  572.         {
  573.             if ( myloc = obj ) return( true );
  574.             if ( myloc.contentsVisible ) return( myloc.isIn( obj ));
  575.         }
  576.         return( nil );
  577.     }
  578.     thrudesc = { "%You% can't see much through "; self.thedesc; ".\n"; }
  579.     moveInto( obj ) =
  580.     {
  581.         local loc;
  582.  
  583.     /*
  584.      *   For the object containing me, and its container, and so forth,
  585.      *   tell it via a Grab message that I'm going away.
  586.      */
  587.     loc := self.location;
  588.     while ( loc )
  589.     {
  590.         loc.Grab( self );
  591.         loc := loc.location;
  592.     }
  593.  
  594.         if ( self.location )
  595.             self.location.contents := self.location.contents - self;
  596.         self.location := obj;
  597.         if ( obj ) obj.contents := obj.contents + self;
  598.     }
  599.     verDoSave( actor ) =
  600.     {
  601.         "Please specify the name of the game to save in double quotes,
  602.         for example, SAVE \"GAME1\". ";
  603.     }
  604.     verDoRestore( actor ) =
  605.     {
  606.         "Please specify the name of the game to restore in double quotes,
  607.         for example, SAVE \"GAME1\". ";
  608.     }
  609.     verDoScript( actor ) =
  610.     {
  611.         "You should type the name of a file to write the transcript to
  612.         in quotes, for example, SCRIPT \"LOG1\". ";
  613.     }
  614.     verDoSay( actor ) =
  615.     {
  616.         "You should say what you want to say in double quotes, for example,
  617.         SAY \"HELLO\". ";
  618.     }
  619.     verDoPush( actor ) =
  620.     {
  621.         "Pushing "; self.thedesc; " doesn't do anything. ";
  622.     }
  623.     verDoWear( actor ) =
  624.     {
  625.         "%You% can't wear "; self.thedesc; ". ";
  626.     }
  627.     verDoTake( actor ) =
  628.     {
  629.         if ( self.location = actor )
  630.         {
  631.             "%You% already %have% "; self.thedesc; "! ";
  632.         }
  633.         else self.verifyRemove( actor );
  634.     }
  635.     verifyRemove( actor ) =
  636.     {
  637.       /*
  638.      *   Check with each container to make sure that the container
  639.      *   doesn't object to the object's removal.
  640.      */
  641.         local loc;
  642.  
  643.         loc := self.location;
  644.         while ( loc )
  645.         {
  646.             if ( loc <> actor ) loc.verGrab( self );
  647.             loc := loc.location;
  648.         }
  649.     }
  650.     isVisible( vantage ) =
  651.     {
  652.         local loc;
  653.  
  654.         loc := self.location;
  655.         if ( loc = nil ) return( nil );
  656.  
  657.         /* if it's in the vantage, it's visible */
  658.         if ( loc = vantage ) return( true );
  659.  
  660.         /*
  661.          *   if its location's contents are visible, and its location is
  662.          *   itself visible, it's visible
  663.          */
  664.         if ( loc.contentsVisible and loc.isVisible( vantage )) return( true );
  665.  
  666.         /*
  667.          *   If the vantage has a location, and the vantage's location's
  668.          *   contents are visible (if you can see me I can see you), and
  669.          *   the object is visible from the vantage's location, the object
  670.          *   is visible
  671.          */
  672.         if ( vantage.location <> nil and vantage.location.contentsVisible and
  673.          self.isVisible( vantage.location ))
  674.             return( true );
  675.  
  676.         /* all tests failed:  it's not visible */
  677.         return( nil );
  678.     }
  679.     cantReach( actor ) =
  680.     {
  681.         if ( self.location = nil )
  682.         {
  683.             if ( actor.location.location )
  684.                "%You% can't reach that from << actor.location.thedesc >>. ";
  685.             return;
  686.         }
  687.         if ( not self.location.isopenable or self.location.isopen )
  688.             self.location.cantReach( actor );
  689.         else "%You%'ll have to open << self.location.thedesc >> first. ";
  690.     }
  691.     isReachable( actor ) =
  692.     {
  693.         local loc;
  694.  
  695.         /* if the object is in the room's 'reachable' list, it's reachable */
  696.         if (find( actor.location.reachable, self ) <> nil )
  697.             return( true );
  698.  
  699.         /*
  700.          *   If the object's container's contents are reachable, and the
  701.          *   container is reachable, the object is reachable.
  702.          */
  703.         loc := self.location;
  704.     if (find( actor.location.reachable, self ) <> nil )
  705.         return( true );
  706.     if ( loc = nil ) return( nil );
  707.     if ( loc = actor or loc = actor.location ) return( true );
  708.     if ( loc.contentsReachable )
  709.         return( loc.isReachable( actor ));
  710.     return( nil );
  711.         return( nil );
  712.     }
  713.     doTake( actor ) =
  714.     {
  715.         local totbulk, totweight;
  716.  
  717.         totbulk := addbulk( actor.contents ) + self.bulk;
  718.         totweight := addweight( actor.contents );
  719.         if ( not actor.isCarrying( self ))
  720.             totweight := totweight + self.weight;
  721.  
  722.         if ( totweight > actor.maxweight )
  723.             "%Your% load is too heavy. ";
  724.         else if ( totbulk > actor.maxbulk )
  725.             "%You've% already got %your% hands full. ";
  726.         else
  727.         {
  728.             self.moveInto( actor );
  729.             "Taken. ";
  730.         }
  731.     }
  732.     verDoDrop( actor ) =
  733.     {
  734.         if ( not actor.isCarrying( self ))
  735.         {
  736.             "%You're% not carrying "; self.thedesc; "! ";
  737.         }
  738.         else self.verifyRemove( actor );
  739.     }
  740.     doDrop( actor ) =
  741.     {
  742.         actor.location.roomDrop( self );
  743.     }
  744.     verDoUnwear( actor ) =
  745.     {
  746.         "%You're% not wearing "; self.thedesc; "! ";
  747.     }
  748.     verIoPutIn( actor ) =
  749.     {
  750.         "I don't know how to put anything into "; self.thedesc; ". ";
  751.     }
  752.     verDoPutIn( actor, io ) =
  753.     {
  754.         if ( io = nil ) return;
  755.  
  756.         if ( self.location = io )
  757.         {
  758.             caps(); self.thedesc; " is already in "; io.thedesc; "! ";
  759.         }
  760.         else if ( io = self or io.isIn( self ))
  761.         {
  762.             "%You% can't put "; self.thedesc; " in itself! ";
  763.         }
  764.         else self.verifyRemove( actor );
  765.     }
  766.     doPutIn( actor, io ) =
  767.     {
  768.         self.moveInto( io );
  769.         "Done. ";
  770.     }
  771.     verIoPutOn( actor ) =
  772.     {
  773.         "There's no good surface on "; self.thedesc; ". ";
  774.     }
  775.     verDoPutOn( actor, io ) =
  776.     {
  777.         if ( io = nil ) return;
  778.  
  779.         if ( self.location = io )
  780.         {
  781.             caps(); self.thedesc; " is already on "; io.thedesc; "! ";
  782.         }
  783.         else if ( io = self or io.isIn( self ))
  784.         {
  785.             "%You% can't put "; self.thedesc; " on itself! ";
  786.         }
  787.         else self.verifyRemove( actor );
  788.     }
  789.     doPutOn( actor, io ) =
  790.     {
  791.         self.moveInto( io );
  792.         "Done. ";
  793.     }
  794.     verIoTakeOut( actor ) = {}
  795.     ioTakeOut( actor, dobj ) =
  796.     {
  797.         dobj.doTakeOut( actor, self );
  798.     }
  799.     verDoTakeOut( actor, io ) =
  800.     {
  801.         if ( io <> nil and not self.isIn( io ))
  802.         {
  803.             caps(); self.thedesc; " isn't in "; io.thedesc; ". ";
  804.         }
  805.     self.verDoTake(actor);         /* ensure object can be taken at all */
  806.     }
  807.     doTakeOut( actor, io ) =
  808.     {
  809.         self.doTake( actor );
  810.     }
  811.     verIoTakeOff( actor ) = {}
  812.     ioTakeOff( actor, dobj ) =
  813.     {
  814.         dobj.doTakeOff( actor, self );
  815.     }
  816.     verDoTakeOff( actor, io ) =
  817.     {
  818.         if ( io <> nil and not self.isIn( io ))
  819.         {
  820.             caps(); self.thedesc; " isn't on "; io.thedesc; "! ";
  821.         }
  822.     self.verDoTake(actor);         /* ensure object can be taken at all */
  823.     }
  824.     doTakeOff( actor, io ) =
  825.     {
  826.         self.doTake( actor );
  827.     }
  828.     verIoPlugIn( actor ) =
  829.     {
  830.         "%You% can't plug anything into "; self.thedesc; ". ";
  831.     }
  832.     verDoPlugIn( actor, io ) =
  833.     {
  834.         "%You% can't plug "; self.thedesc; " into anything. ";
  835.     }
  836.     verIoUnplugFrom( actor ) =
  837.     {
  838.         "It's not plugged into "; self.thedesc; ". ";
  839.     }
  840.     verDoUnplugFrom( actor, io ) =
  841.     {
  842.         if ( io <> nil ) { "It's not plugged into "; io.thedesc; ". "; }
  843.     }
  844.     verDoLookin( actor ) =
  845.     {
  846.         "There's nothing in "; self.thedesc; ". ";
  847.     }
  848.     verDoLookthru( actor ) =
  849.     {
  850.         "%You% can't see anything through "; self.thedesc; ". ";
  851.     }
  852.     verDoLookunder( actor ) =
  853.     {
  854.         "There's nothing under "; self.thedesc; ". ";
  855.     }
  856.     verDoInspect( actor ) = {}
  857.     doInspect( actor ) =
  858.     {
  859.         self.ldesc;
  860.     }
  861.     verDoRead( actor ) =
  862.     {
  863.         "I don't know how to read "; self.thedesc; ". ";
  864.     }
  865.     verDoLookbehind( actor ) =
  866.     {
  867.         "There's nothing behind "; self.thedesc; ". ";
  868.     }
  869.     verDoTurn( actor ) =
  870.     {
  871.         "Turning "; self.thedesc; " doesn't have any effect. ";
  872.     }
  873.     verDoTurnWith( actor, io ) =
  874.     {
  875.         "Turning "; self.thedesc; " doesn't have any effect. ";
  876.     }
  877.     verDoTurnTo( actor, io ) =
  878.     {
  879.         "Turning "; self.thedesc; " doesn't have any effect. ";
  880.     }
  881.     verIoTurnTo( actor ) =
  882.     {
  883.         "I don't know how to do that. ";
  884.     }
  885.     verDoTurnon( actor ) =
  886.     {
  887.         "I don't know how to turn "; self.thedesc; " on. ";
  888.     }
  889.     verDoTurnoff( actor ) =
  890.     {
  891.         "I don't know how to turn "; self.thedesc; " off. ";
  892.     }
  893.     verIoAskAbout( actor ) = {}
  894.     ioAskAbout( actor, dobj ) =
  895.     {
  896.         dobj.doAskAbout( actor, self );
  897.     }
  898.     verDoAskAbout( actor, io ) =
  899.     {
  900.         "Surely, %you% can't think "; self.thedesc; " knows anything
  901.         about it! ";
  902.     }
  903.     verIoTellAbout( actor ) = {}
  904.     ioTellAbout( actor, dobj ) =
  905.     {
  906.         dobj.doTellAbout( actor, self );
  907.     }
  908.     verDoTellAbout( actor, io ) =
  909.     {
  910.         "It doesn't look as though "; self.thedesc; " is interested. ";
  911.     }
  912.     verDoUnboard( actor ) =
  913.     {
  914.         if ( actor.location <> self )
  915.         {
  916.             "%You're% not in "; self.thedesc; "! ";
  917.         }
  918.         else if ( self.location=nil )
  919.         {
  920.             "%You% can't get out of "; self.thedesc; "! ";
  921.         }
  922.     }
  923.     doUnboard( actor ) =
  924.     {
  925.         if ( self.fastenitem )
  926.     {
  927.         "%You%'ll have to unfasten "; actor.location.fastenitem.thedesc;
  928.         " first. ";
  929.     }
  930.     else
  931.     {
  932.             "Okay, %you're% no longer in "; self.thedesc; ". ";
  933.             self.leaveRoom( actor );
  934.         actor.moveInto( self.location );
  935.     }
  936.     }
  937.     verDoAttackWith( actor, io ) =
  938.     {
  939.         "Attacking "; self.thedesc; " doesn't appear productive. ";
  940.     }
  941.     verIoAttackWith( actor ) =
  942.     {
  943.         "It's not very effective to attack with "; self.thedesc; ". ";
  944.     }
  945.     verDoEat( actor ) =
  946.     {
  947.         caps(); self.thedesc; " doesn't appear appetizing. ";
  948.     }
  949.     verDoDrink( actor ) =
  950.     {
  951.         caps(); self.thedesc; " doesn't appear appetizing. ";
  952.     }
  953.     verDoGiveTo( actor, io ) =
  954.     {
  955.         if ( not actor.isCarrying( self ))
  956.         {
  957.             "%You're% not carrying "; self.thedesc; ". ";
  958.         }
  959.         else self.verifyRemove( actor );
  960.     }
  961.     doGiveTo( actor, io ) =
  962.     {
  963.         self.moveInto( io );
  964.         "Done. ";
  965.     }
  966.     verDoPull( actor ) =
  967.     {
  968.         "Pulling "; self.thedesc; " doesn't have any effect. ";
  969.     }
  970.     verDoThrowAt( actor, io ) =
  971.     {
  972.         if ( not actor.isCarrying( self ))
  973.         {
  974.             "%You're% not carrying "; self.thedesc; ". ";
  975.         }
  976.         else self.verifyRemove( actor );
  977.     }
  978.     doThrowAt( actor, io ) =
  979.     {
  980.         "%You% miss%es%. ";
  981.         self.moveInto( actor.location );
  982.     }
  983.     verIoThrowAt( actor ) =
  984.     {
  985.         if ( actor.isCarrying( self ))
  986.         {
  987.             "%You% could at least drop "; self.thedesc; " first. ";
  988.         }
  989.     }
  990.     ioThrowAt( actor, dobj ) =
  991.     {
  992.         dobj.doThrowAt( actor, self );
  993.     }
  994.     verDoThrowTo( actor, io ) =
  995.     {
  996.         if ( not actor.isCarrying( self ))
  997.         {
  998.             "%You're% not carrying "; self.thedesc; ". ";
  999.         }
  1000.         else self.verifyRemove( actor );
  1001.     }
  1002.     doThrowTo( actor, io ) =
  1003.     {
  1004.         "%You% miss%es%. ";
  1005.         self.moveInto( actor.location );
  1006.     }
  1007.     verDoThrow( actor ) =
  1008.     {
  1009.         if ( not actor.isCarrying( self ))
  1010.         {
  1011.             "%You're% not carrying "; self.thedesc; ". ";
  1012.         }
  1013.         else self.verifyRemove( actor );
  1014.     }
  1015.     doThrow( actor ) =
  1016.     {
  1017.         "Thrown. ";
  1018.         self.moveInto( actor.location );
  1019.     }
  1020.     verDoShowTo( actor, io ) =
  1021.     {
  1022.     }
  1023.     doShowTo( actor, io ) =
  1024.     {
  1025.         if ( io <> nil ) { caps(); io.thedesc; " isn't impressed. "; }
  1026.     }
  1027.     verIoShowTo( actor ) =
  1028.     {
  1029.         caps(); self.thedesc; " isn't impressed. ";
  1030.     }
  1031.     verDoClean( actor ) =
  1032.     {
  1033.         caps(); self.thedesc; " looks a bit cleaner now. ";
  1034.     }
  1035.     verDoCleanWith( actor, io ) = {}
  1036.     doCleanWith( actor, io ) =
  1037.     {
  1038.         caps(); self.thedesc; " looks a bit cleaner now. ";
  1039.     }
  1040.     verDoMove( actor ) =
  1041.     {
  1042.         "Moving "; self.thedesc; " doesn't reveal anything. ";
  1043.     }
  1044.     verDoMoveTo( actor, io ) =
  1045.     {
  1046.         "Moving "; self.thedesc; " doesn't reveal anything. ";
  1047.     }
  1048.     verIoMoveTo( actor ) =
  1049.     {
  1050.         "That doesn't get us anywhere. ";
  1051.     }
  1052.     verDoMoveWith( actor, io ) =
  1053.     {
  1054.         "Moving "; self.thedesc; " doesn't reveal anything. ";
  1055.     }
  1056.     verIoMoveWith( actor ) =
  1057.     {
  1058.         caps(); self.thedesc; " doesn't seem to help. ";
  1059.     }
  1060.     verDoTypeOn( actor, io ) =
  1061.     {
  1062.         "You should say what you want to type in double quotes, for
  1063.         example, TYPE \"HELLO\" ON KEYBOARD. ";
  1064.     }
  1065.     verDoTouch( actor ) =
  1066.     {
  1067.         "Touching "; self.thedesc; " doesn't seem to have any effect. ";
  1068.     }
  1069.     verDoPoke( actor ) =
  1070.     {
  1071.         "Poking "; self.thedesc; " doesn't seem to have any effect. ";
  1072.     }
  1073.     genMoveDir = { "%You% can't seem to do that. "; }
  1074.     verDoMoveN( actor ) = { self.genMoveDir; }
  1075.     verDoMoveS( actor ) = { self.genMoveDir; }
  1076.     verDoMoveE( actor ) = { self.genMoveDir; }
  1077.     verDoMoveW( actor ) = { self.genMoveDir; }
  1078.     verDoMoveNE( actor ) = { self.genMoveDir; }
  1079.     verDoMoveNW( actor ) = { self.genMoveDir; }
  1080.     verDoMoveSE( actor ) = { self.genMoveDir; }
  1081.     verDoMoveSW( actor ) = { self.genMoveDir; }
  1082.     verDoSearch( actor ) =
  1083.     {
  1084.         "%You% find%s% nothing of interest. ";
  1085.     }
  1086. ;
  1087.  
  1088. /*
  1089.  *  item: thing
  1090.  *
  1091.  *  A basic item which can be picked up by the player.  It has no weight
  1092.  *  (0) and minimal bulk (1).  The weight property should be set
  1093.  *  to a non-zero value for heavy objects.  The bulk property
  1094.  *  should be set to a value greater than 1 for bulky objects, and to
  1095.  *  zero for objects that are very small and take essentially no effort
  1096.  *  to hold---or, more precisely, don't detract at all from the player's
  1097.  *  ability to hold other objects (for example, a piece of paper).
  1098. */
  1099. class item: thing
  1100.     weight = 0
  1101.     bulk = 1
  1102. ;
  1103.     
  1104. /*
  1105.  *  lightsource: item
  1106.  *
  1107.  *  A portable lamp, candle, match, or other source of light.  The
  1108.  *  light source can be turned on and off with the islit property.
  1109.  *  If islit is true, the object provides light, otherwise it's
  1110.  *  just an ordinary object.
  1111. */
  1112. class lightsource: item
  1113.     islamp = true
  1114. ;
  1115.  
  1116. /*
  1117.  *  hiddenItem: object
  1118.  *
  1119.  *  This is an object that is hidden with one of the hider classes. 
  1120.  *  A hiddenItem object doesn't have any special properties in its
  1121.  *  own right, but all objects hidden with one of the hider classes
  1122.  *  must be of class hiddenItem so that initSearch can find
  1123.  *  them.
  1124. */
  1125. class hiddenItem: object
  1126. ;
  1127.  
  1128. /*
  1129.  *  hider: item
  1130.  *
  1131.  *  This is a basic class of object that can hide other objects in various
  1132.  *  ways.  The underHider, behindHider, and searchHider classes
  1133.  *  are examples of hider subclasses.  The class defines
  1134.  *  the method searchObj(actor, list), which is given the list
  1135.  *  of hidden items contained in the object (for example, this would be the
  1136.  *  underCont property, in the case of an underHider), and "finds"
  1137.  *  the object or objects. Its action is dependent upon a couple of other
  1138.  *  properties of the hider object.  The serialSearch property,
  1139.  *  if true, indicates that items in the list are to be found one at
  1140.  *  a time; if nil (the default), the entire list is found on the
  1141.  *  first try.  The autoTake property, if true, indicates that
  1142.  *  the actor automatically takes the item or items found; if nil, the
  1143.  *  item or items are moved to the actor's location.  The searchObj method
  1144.  *  returns the list with the found object or objects removed; the
  1145.  *  caller should assign this returned value back to the appropriate
  1146.  *  property (for example, underHider will assign the return value
  1147.  *  to underCont).
  1148.  *  
  1149.  *  Note that because the hider is hiding something, this class
  1150.  *  overrides the normal verDoSearch method to display the
  1151.  *  message, "You'll have to be more specific about how you want
  1152.  *  to search that."  The reason is that the normal verDoSearch
  1153.  *  message ("You find nothing of interest") leads players to believe
  1154.  *  that the object was exhaustively searched, and we want to avoid
  1155.  *  misleading the player.  On the other hand, we don't want a general
  1156.  *  search to be exhaustive for most hider objects.  So, we just
  1157.  *  display a message letting the player know that the search was not
  1158.  *  enough, but we don't give away what they have to do instead.
  1159.  *  
  1160.  *  The objects hidden with one of the hider classes must be
  1161.  *  of class hiddenItem.
  1162. */
  1163. class hider: item
  1164.     verDoSearch(actor) =
  1165.     {
  1166.     "%You%'ll have to be more specific about how %you% want%s%
  1167.     to search that. ";
  1168.     }
  1169.     searchObj(actor, list) =
  1170.     {
  1171.     local found, dest, i, tot;
  1172.  
  1173.     /* see how much we get this time */
  1174.     if (self.serialSearch)
  1175.     {
  1176.         found := [] + car(list);
  1177.         list := cdr(list);
  1178.     }
  1179.     else
  1180.     {
  1181.         found := list;
  1182.         list := nil;
  1183.     }
  1184.  
  1185.     /* figure destination */
  1186.     dest := actor;
  1187.     if (not self.autoTake) dest := dest.location;
  1188.     
  1189.     /* note what we found, and move it to destination */
  1190.     "%You% find%s% ";
  1191.     tot := length(found);
  1192.     i := 1;
  1193.     while (i <= tot)
  1194.     {
  1195.         found[i].adesc;
  1196.         if (i+1 < tot) ", ";
  1197.         else if (i = 1 and tot = 2) " and ";
  1198.         else if (i+1 = tot and tot > 2) ", and ";
  1199.         
  1200.         found[i].moveInto(dest);
  1201.         i := i + 1;
  1202.     }
  1203.  
  1204.     /* say what happened */
  1205.     if (self.autoTake) ", which %you% take%s%. ";
  1206.     else "! ";
  1207.  
  1208.     if (list<>nil and length(list)=0) list := nil;
  1209.     return(list);
  1210.     }
  1211.     serialSearch = nil             /* find everything in one try by default */
  1212.     autoTake = true               /* actor takes item when found by default */
  1213. ;
  1214.  
  1215. /*
  1216.  *  underHider: hider
  1217.  *
  1218.  *  This is an object that can have other objects placed under it.  The
  1219.  *  objects placed under it can only be found by looking under the object;
  1220.  *  see the description of hider for more information.  You should
  1221.  *  set the underLoc property of each hidden object to point to
  1222.  *  the underHider.
  1223.  *  
  1224.  *  Note that an underHider doesn't allow the player to put anything
  1225.  *  under the object during the game.  Instead, it's to make it easy for the
  1226.  *  game writer to set up hidden objects while implementing the game.  All you
  1227.  *  need to do to place an object under another object is declare the top
  1228.  *  object as an underHider, then declare the hidden object normally,
  1229.  *  except use underLoc rather than location to specify the
  1230.  *  location of the hidden object.  The behindHider and searchHider
  1231.  *  objects work similarly.
  1232.  *  
  1233.  *  The objects hidden with underHider must be of class hiddenItem.
  1234. */
  1235. class underHider: hider
  1236.     underCont = []         /* list of items under me (set up by initSearch) */
  1237.     verDoLookunder(actor) = {}
  1238.     doLookunder(actor) =
  1239.     {
  1240.     if (self.underCont = nil)
  1241.         "There's nothing else under <<self.thedesc>>. ";
  1242.     else
  1243.         self.underCont := self.searchObj(actor, self.underCont);
  1244.     }
  1245. ;
  1246.  
  1247. /*
  1248.  *  behindHider: hider
  1249.  *
  1250.  *  This is just like an underHider, except that objects are hidden
  1251.  *  behind this object.  Objects to be behind this object should have their
  1252.  *  behindLoc property set to point to this object.
  1253.  *  
  1254.  *  The objects hidden with behindHider must be of class hiddenItem.
  1255. */
  1256. class behindHider: hider
  1257.     behindCont = []
  1258.     verDoLookbehind(actor) = {}
  1259.     doLookbehind(actor) =
  1260.     {
  1261.     if (self.behindCont = nil)
  1262.         "There's nothing else behind <<self.thedesc>>. ";
  1263.     else
  1264.         self.behindCont := self.searchObj(actor, self.behindCont);
  1265.     }
  1266. ;
  1267.     
  1268. /*
  1269.  *  searchHider: hider
  1270.  *
  1271.  *  This is just like an underHider, except that objects are hidden
  1272.  *  within this object in such a way that the object must be looked in
  1273.  *  or searched.  Objects to be hidden in this object should have their
  1274.  *  searchLoc property set to point to this object.  Note that this
  1275.  *  is different from a normal container, in that the objects hidden within
  1276.  *  this object will not show up until the object is explicitly looked in
  1277.  *  or searched.
  1278.  *  
  1279.  *  The items hidden with searchHider must be of class hiddenItem.
  1280. */
  1281. class searchHider: hider
  1282.     searchCont = []
  1283.     verDoSearch(actor) = {}
  1284.     doSearch(actor) =
  1285.     {
  1286.     if (self.searchCont = nil)
  1287.         "There's nothing else in <<self.thedesc>>. ";
  1288.     else
  1289.         self.searchCont := self.searchObj(actor, self.searchCont);
  1290.     }
  1291.     verDoLookin(actor) =
  1292.     {
  1293.     if (self.searchCont = nil)
  1294.         pass verDoLookin;
  1295.     }
  1296.     doLookin(actor) =
  1297.     {
  1298.     if (self.searchCont = nil)
  1299.         pass doLookin;
  1300.     else
  1301.         self.searchCont := self.searchObj(actor, self.searchCont);
  1302.     }
  1303. ;
  1304.     
  1305.  
  1306. /*
  1307.  *  fixeditem: thing
  1308.  *
  1309.  *  An object that cannot be taken or otherwise moved from its location.
  1310.  *  Note that a fixeditem is sometimes part of a movable object;
  1311.  *  this can be done to make one object part of another, ensuring that
  1312.  *  they cannot be separated.  By default, the functions that list a room's
  1313.  *  contents do not automatically describe fixeditem objects (because
  1314.  *  the isListed property is set to nil).  Instead, the game author
  1315.  *  will generally describe the fixeditem objects separately as part of
  1316.  *  the room's ldesc.  
  1317. */
  1318. class fixeditem: thing      // An immovable object
  1319.     isListed = nil          // not listed in room/inventory displays
  1320.     isfixed = true          // Item can't be taken
  1321.     weight = 0              // no actual weight
  1322.     bulk = 0
  1323.     verDoTake( actor ) =
  1324.     {
  1325.         "%You% can't have "; self.thedesc; ". ";
  1326.     }
  1327.     verDoTakeOut( actor, io ) =
  1328.     {
  1329.         self.verDoTake( actor );
  1330.     }
  1331.     verDoDrop( actor ) =
  1332.     {
  1333.         "%You% can't drop "; self.thedesc; ". ";
  1334.     }
  1335.     verDoTakeOff( actor, io ) =
  1336.     {
  1337.         self.verDoTake( actor );
  1338.     }
  1339.     verDoPutIn( actor, io ) =
  1340.     {
  1341.         "%You% can't put "; self.thedesc; " anywhere. ";
  1342.     }
  1343.     verDoPutOn( actor, io ) =
  1344.     {
  1345.         "%You% can't put "; self.thedesc; " anywhere. ";
  1346.     }
  1347.     verDoMove( actor ) =
  1348.     {
  1349.         "%You% can't move "; self.thedesc; ". ";
  1350.     }
  1351. ;
  1352.  
  1353. /*
  1354.  *  readable: item
  1355.  *
  1356.  *  An item that can be read.  The readdesc property is displayed
  1357.  *  when the item is read.  By default, the readdesc is the same
  1358.  *  as the ldesc, but the readdesc can be overridden to give
  1359.  *  a different message.
  1360. */
  1361. class readable: item
  1362.     verDoRead( actor ) =
  1363.     {
  1364.     }
  1365.     doRead( actor ) =
  1366.     {
  1367.         self.readdesc;
  1368.     }
  1369.     readdesc =
  1370.     {
  1371.         self.ldesc;
  1372.     }
  1373. ;
  1374.  
  1375. /*
  1376.  *  fooditem: item
  1377.  *
  1378.  *  An object that can be eaten.  When eaten, the object is removed from
  1379.  *  the game, and global.lastMealTime is decremented by the
  1380.  *  foodvalue property.  By default, the foodvalue property
  1381.  *  is global.eatTime, which is the time between meals.  So, the
  1382.  *  default fooditem will last for one "nourishment interval."
  1383. */
  1384. class fooditem: item
  1385.     verDoEat( actor ) =
  1386.     {
  1387.         self.verifyRemove( actor );
  1388.     }
  1389.     doEat( actor ) =
  1390.     {
  1391.         "That was delicious! ";
  1392.         global.lastMealTime := global.lastMealTime - self.foodvalue;
  1393.         self.moveInto( nil );
  1394.     }
  1395.     foodvalue = { return( global.eatTime ); }
  1396. ;
  1397.  
  1398. /*
  1399.  *  dialItem: fixeditem
  1400.  *
  1401.  *  This class is used for making "dials," which are controls in
  1402.  *  your game that can be turned to a range of numbers.  You must
  1403.  *  define the property maxsetting as a number specifying the
  1404.  *  highest number to which the dial can be turned; the lowest number
  1405.  *  on the dial is always 1.  The setting property is the dial's
  1406.  *  current setting, and can be changed by the player by typing the
  1407.  *  command "turn dial to number."  By default, the ldesc
  1408.  *  method displays the current setting.
  1409. */
  1410. class dialItem: fixeditem
  1411.     maxsetting = 10 // it has settings from 1 to this number
  1412.     setting = 1     // the current setting
  1413.     ldesc =
  1414.     {
  1415.         caps(); self.thedesc; " can be turned to settings
  1416.         numbered from 1 to << self.maxsetting >>. It's
  1417.         currently set to << self.setting >>. ";
  1418.     }
  1419.     verDoTurn( actor ) = {}
  1420.     doTurn( actor ) =
  1421.     {
  1422.         askio( toPrep );
  1423.     }
  1424.     verDoTurnTo( actor, io ) = {}
  1425.     doTurnTo( actor, io ) =
  1426.     {
  1427.         if ( io = numObj )
  1428.         {
  1429.             if ( numObj.value < 1 or numObj.value > self.maxsetting )
  1430.             {
  1431.                 "There's no such setting! ";
  1432.             }
  1433.             else if ( numObj.value <> self.setting )
  1434.             {
  1435.                 self.setting := numObj.value;
  1436.                 "Okay, it's now turned to "; say( self.setting ); ". ";
  1437.             }
  1438.             else
  1439.             {
  1440.                 "It's already set to "; say( self.setting ); "! ";
  1441.             }
  1442.         }
  1443.         else
  1444.         {
  1445.             "I don't know how to turn "; self.thedesc;
  1446.             " to that. ";
  1447.         }
  1448.     }
  1449. ;
  1450.  
  1451. /*
  1452.  *  switchItem: fixeditem
  1453.  *
  1454.  *  This is a class for things that can be turned on and off by the
  1455.  *  player.  The only special property is isActive, which is nil
  1456.  *  if the switch is turned off and true when turned on.  The object
  1457.  *  accepts the commands "turn it on" and "turn it off,'' as well as
  1458.  *  synonymous constructions, and updates isActive accordingly.
  1459. */
  1460. class switchItem: fixeditem
  1461.     verDoSwitch( actor ) = {}
  1462.     doSwitch( actor ) =
  1463.     {
  1464.         self.isActive := not self.isActive;
  1465.         "Okay, "; self.thedesc; " is now switched ";
  1466.         if ( self.isActive ) "on"; else "off";
  1467.         ". ";
  1468.     }
  1469.     verDoTurnon( actor ) =
  1470.     {
  1471.         if ( self.isActive ) "It's already turned on! ";
  1472.     }
  1473.     doTurnon( actor ) =
  1474.     {
  1475.         self.isActive := true;
  1476.         "Okay, it's now turned on. ";
  1477.     }
  1478.     verDoTurnoff( actor ) =
  1479.     {
  1480.         if ( not self.isActive ) "It's already turned off! ";
  1481.     }
  1482.     doTurnoff( actor ) =
  1483.     {
  1484.         self.isActive := nil;
  1485.         "Okay, it's now turned off. ";
  1486.     }
  1487. ;
  1488.  
  1489. /*
  1490.  *  room: thing
  1491.  *
  1492.  *  A location in the game.  By default, the islit property is
  1493.  *  true, which means that the room is lit (no light source is
  1494.  *  needed while in the room).  You should create a darkroom
  1495.  *  object rather than a room with islit set to nil if you
  1496.  *  want a dark room, because other methods are affected as well.
  1497.  *  The isseen property records whether the player has entered
  1498.  *  the room before; initially it's nil, and is set to true
  1499.  *  the first time the player enters.  The roomAction(actor,
  1500.  *  verb, directObject, preposition, indirectObject) method is
  1501.  *  activated for each player command; by default, all it does is
  1502.  *  call the room's location's roomAction method if the room
  1503.  *  is inside another room.  The lookAround(verbosity)
  1504.  *  method displays the room's description for a given verbosity
  1505.  *  level; true means a full description, nil means only
  1506.  *  the short description (just the room name plus a list of the
  1507.  *  objects present).  roomDrop(object) is called when
  1508.  *  an object is dropped within the room; normally, it just moves
  1509.  *  the object to the room and displays "Dropped."  The firstseen
  1510.  *  method is called when isseen is about to be set true
  1511.  *  for the first time (i.e., when the player first sees the room);
  1512.  *  by default, this routine does nothing, but it's a convenient
  1513.  *  place to put any special code you want to execute when a room
  1514.  *  is first entered.  The firstseen method is called after
  1515.  *  the room's description is displayed.
  1516. */
  1517. class room: thing
  1518.     /*
  1519.      *   'reachable' is the list of explicitly reachable objects, over and
  1520.      *   above the objects that are here.  This is mostly used in nested
  1521.      *   rooms to make objects in the containing room accessible.  Most
  1522.      *   normal rooms will leave this as an empty list.
  1523.      */
  1524.     reachable = []
  1525.     
  1526.     /*
  1527.      *   roomCheck is true if the verb is valid in the room.  This
  1528.      *   is a first pass; generally, its only function is to disallow
  1529.      *   certain commands in a dark room.
  1530.      */
  1531.     roomCheck( v ) = { return( true ); }
  1532.     islit = true            // rooms are lit unless otherwise specified
  1533.     isseen = nil            // room has not been seen yet
  1534.     enterRoom( actor ) =    // sent to room as actor is entering it
  1535.     {
  1536.         self.lookAround(( not self.isseen ) or global.verbose );
  1537.         if ( self.islit )
  1538.     {
  1539.         if (not self.isseen) self.firstseen;
  1540.         self.isseen := true;
  1541.     }
  1542.     }
  1543.     roomAction( a, v, d, p, i ) =
  1544.     {
  1545.         if ( self.location ) self.location.roomAction( a, v, d, p, i );
  1546.     }
  1547.  
  1548.     /*
  1549.      *   Whenever a normal object (i.e., one that does not override the
  1550.      *   default doDrop provided by 'thing') is dropped, the actor's
  1551.      *   location is sent roomDrop(object being dropped).  By default, 
  1552.      *   we move the object into this room.
  1553.      */
  1554.     roomDrop( obj ) =
  1555.     {
  1556.         "Dropped. ";
  1557.     obj.moveInto( self );
  1558.     }
  1559.  
  1560.     /*
  1561.      *   Whenever an actor leaves this room, we run through the leaveList.
  1562.      *   This is a list of objects that have registered themselves with us
  1563.      *   via addLeaveList().  For each object in the leaveList, we send
  1564.      *   a "leaving" message, with the actor as the parameter.  It should
  1565.      *   return true if it wants to be removed from the leaveList, nil
  1566.      *   if it wants to stay.
  1567.      */
  1568.     leaveList = []
  1569.     addLeaveList( obj ) =
  1570.     {
  1571.         self.leaveList := self.leaveList + obj;
  1572.     }
  1573.     leaveRoom( actor ) =
  1574.     {
  1575.         local tmplist, thisobj, i, tot;
  1576.  
  1577.         tmplist := self.leaveList;
  1578.     tot := length( tmplist );
  1579.     i := 1;
  1580.         while ( i <= tot )
  1581.         {
  1582.         thisobj := tmplist[i];
  1583.             if ( thisobj.leaving( actor ))
  1584.                 self.leaveList := self.leaveList - thisobj;
  1585.             i := i + 1;
  1586.         }
  1587.     }
  1588.     /*
  1589.      *   lookAround describes the room.  If verbosity is true, the full
  1590.      *   description is given, otherwise an abbreviated description (without
  1591.      *   the room's ldesc) is displayed.
  1592.      */
  1593.     nrmLkAround( verbosity ) =      // lookAround without location status
  1594.     {
  1595.         local l, cur, i, tot;
  1596.  
  1597.         if ( verbosity )
  1598.         {
  1599.             "\n\t"; self.ldesc;
  1600.  
  1601.             l := self.contents;
  1602.         tot := length( l );
  1603.         i := 1;
  1604.             while ( i <= tot )
  1605.             {
  1606.             cur := l[i];
  1607.                 if ( cur.isfixed ) cur.heredesc;
  1608.                 i := i + 1;
  1609.             }
  1610.         }
  1611.         "\n\t";
  1612.         if (itemcnt( self.contents ))
  1613.         {
  1614.             "You see "; listcont( self ); " here. ";
  1615.         }
  1616.         listcontcont( self ); "\n";
  1617.  
  1618.         l := self.contents;
  1619.     tot := length( l );
  1620.     i := 1;
  1621.         while ( i <= tot )
  1622.         {
  1623.         cur := l[i];
  1624.             if ( cur.isactor )
  1625.             {
  1626.                 if ( cur <> Me )
  1627.                 {
  1628.                     "\n\t";
  1629.                     cur.actorDesc;
  1630.                 }
  1631.             }
  1632.             i := i + 1;
  1633.         }
  1634.     }
  1635.     statusLine =
  1636.     {
  1637.         self.sdesc; "\n\t";
  1638.     }
  1639.     lookAround( verbosity ) =
  1640.     {
  1641.         self.statusLine;
  1642.         self.nrmLkAround( verbosity );
  1643.     }
  1644.     
  1645.     /*
  1646.      *   Direction handlers.  The directions are all set up to
  1647.      *   the default, which is no travel allowed.  To make travel
  1648.      *   possible in a direction, just assign a room to the direction
  1649.      *   property.
  1650.      */
  1651.     north = { return( self.noexit ); }
  1652.     south = { return( self.noexit ); }
  1653.     east  = { return( self.noexit ); }
  1654.     west  = { return( self.noexit ); }
  1655.     up    = { return( self.noexit ); }
  1656.     down  = { return( self.noexit ); }
  1657.     ne    = { return( self.noexit ); }
  1658.     nw    = { return( self.noexit ); }
  1659.     se    = { return( self.noexit ); }
  1660.     sw    = { return( self.noexit ); }
  1661.     in    = { return( self.noexit ); }
  1662.     out   = { return( self.noexit ); }
  1663.     
  1664.     /*
  1665.      *   noexit displays a message when the player attempts to travel
  1666.      *   in a direction in which travel is not possible.
  1667.      */
  1668.     noexit = { "%You% can't go that way. "; return( nil ); }
  1669. ;
  1670.  
  1671. /*
  1672.  *  darkroom: room
  1673.  *
  1674.  *  A dark room.  The player must have some object that can act as a
  1675.  *  light source in order to move about and perform most operations
  1676.  *  while in this room.  Note that the room's lights can be turned
  1677.  *  on by setting the room's lightsOn property to true;
  1678.  *  do this instead of setting islit, because islit is
  1679.  *  a method which checks for the presence of a light source.
  1680. */
  1681. class darkroom: room        // An enterable area which might be dark
  1682.     islit =                 // true ONLY if something is lighting the room
  1683.     {
  1684.         local rem, cur, tot, i;
  1685.  
  1686.     if ( self.lightsOn ) return( true );
  1687.  
  1688.     rem := global.lamplist;
  1689.     tot := length( rem );
  1690.     i := 1;
  1691.     while ( i <= tot )
  1692.     {
  1693.         cur := rem[i];
  1694.         if ( cur.isIn( self ) and cur.islit ) return( true );
  1695.         i := i + 1;
  1696.     }
  1697.     return( nil );
  1698.     }
  1699.     roomAction( actor, v, dobj, prep, io ) =
  1700.     {
  1701.         if ( not self.islit and not v.isTravelVerb and not v.issysverb )
  1702.     {
  1703.         "%You% can't see a thing. ";
  1704.         exit;
  1705.     }
  1706.     else pass roomAction;
  1707.     }
  1708.     statusLine =
  1709.     {
  1710.         if ( self.islit ) pass statusLine;
  1711.     else "In the dark.";
  1712.     }
  1713.     lookAround( verbosity ) =
  1714.     {
  1715.         if ( self.islit ) pass lookAround;
  1716.     else "It's pitch black. ";
  1717.     }
  1718.     noexit =
  1719.     {
  1720.         if ( self.islit ) pass noexit;
  1721.     else
  1722.     {
  1723.         darkTravel();
  1724.         return( nil );
  1725.     }
  1726.     }
  1727.     roomCheck( v ) =
  1728.     {
  1729.         if ( self.islit or v.issysverb or v.isTravelVerb ) return( true );
  1730.     else
  1731.     {
  1732.         "It's pitch black.\n";
  1733.         return( nil );
  1734.     }
  1735.     }
  1736. ;
  1737.  
  1738. /*
  1739.  *  theFloor is a special item that appears in every room (hence
  1740.  *  the non-standard location property).  This object is included
  1741.  *  mostly for completeness, so that the player can refer to the
  1742.  *  floor; otherwise, it doesn't do much.  Dropping an item on the
  1743.  *  floor, for example, moves it to the current room.
  1744.  */
  1745. theFloor: beditem
  1746.     noun = 'floor' 'ground'
  1747.     sdesc = "ground"
  1748.     adesc = "the ground"
  1749.     location =
  1750.     {
  1751.         if ( Me.location = self )
  1752.             return( self.sitloc );
  1753.         else
  1754.             return( Me.location );
  1755.     }
  1756.     locationOK = true        // suppress warning about location being a method
  1757.     doSiton( actor ) =
  1758.     {
  1759.         "Okay, %you're% now sitting on "; self.thedesc; ". ";
  1760.         self.sitloc := actor.location;
  1761.         actor.moveInto( self );
  1762.     }
  1763.     doLieon( actor ) =
  1764.     {
  1765.         self.doSiton( actor );
  1766.     }
  1767.     ioPutOn( actor, dobj ) =
  1768.     {
  1769.         dobj.doDrop( actor );
  1770.     }
  1771.     ioPutIn( actor, dobj ) =
  1772.     {
  1773.         dobj.doDrop( actor );
  1774.     }
  1775. ;
  1776.  
  1777. /*
  1778.  *  Actor: fixeditem, movableActor
  1779.  *
  1780.  *  A character in the game.  The maxweight property specifies
  1781.  *  the maximum weight that the character can carry, and the maxbulk
  1782.  *  property specifies the maximum bulk the character can carry.  The
  1783.  *  actorAction(verb, directObject, preposition, indirectObject)
  1784.  *  method specifies what happens when the actor is given a command by
  1785.  *  the player; by default, the actor ignores the command and displays
  1786.  *  a message to this effect.  The isCarrying(object)
  1787.  *  method returns true if the object is being carried by
  1788.  *  the actor.  The actorDesc method displays a message when the
  1789.  *  actor is in the current room; this message is displayed along with
  1790.  *  a room's description when the room is entered or examined.  The
  1791.  *  verGrab(object) method is called when someone tries to
  1792.  *  take an object the actor is carrying; by default, an actor won't
  1793.  *  let other characters take its possessions.
  1794.  *  
  1795.  *  If you want the player to be able to follow the actor when it
  1796.  *  leaves the room, you should define a follower object to shadow
  1797.  *  the character, and set the actor's myfollower property to
  1798.  *  the follower object.  The follower is then automatically
  1799.  *  moved around just behind the actor by the actor's moveInto
  1800.  *  method.
  1801.  *  
  1802.  *  The isHim property should return true if the actor can
  1803.  *  be referred to by the player as "him," and likewise isHer
  1804.  *  should be set to true if the actor can be referred to as "her."
  1805.  *  Note that both or neither can be set; if neither is set, the actor
  1806.  *  can only be referred to as "it," and if both are set, any of "him,''
  1807.  *  "her," or "it'' will be accepted.
  1808. */
  1809. class Actor: fixeditem, movableActor
  1810. ;
  1811.  
  1812. /*
  1813.  *  movableActor: qcontainer
  1814.  *
  1815.  *  Just like an Actor object, except that the player can
  1816.  *  manipulate the actor like an ordinary item.  Useful for certain
  1817.  *  types of actors, such as small animals.
  1818. */
  1819. class movableActor: qcontainer // A character in the game
  1820.     isListed = nil          // described separately from room's contents
  1821.     weight = 10             // actors are pretty heavy
  1822.     bulk = 10               // and pretty bulky
  1823.     maxweight = 50          // Weight that can be carried at once
  1824.     maxbulk = 20            // Number of objects that can be carried at once
  1825.     isactor = true          // flag that this is an actor
  1826.     actorAction( v, d, p, i ) =
  1827.     {
  1828.         caps(); self.thedesc; " doesn't appear interested. ";
  1829.         exit;
  1830.     }
  1831.     isCarrying( obj ) = { return( obj.isIn( self )); }
  1832.     actorDesc =
  1833.     {
  1834.         caps(); self.adesc; " is here. ";
  1835.     }
  1836.     verGrab( item ) =
  1837.     {
  1838.         caps(); self.thedesc; " is carrying "; item.thedesc;
  1839.         " and won't let %youm% have it. ";
  1840.     }
  1841.     verDoFollow( actor ) =
  1842.     {
  1843.         "But "; self.thedesc; " is right here! ";
  1844.     }
  1845.     moveInto( obj ) =
  1846.     {
  1847.         if ( self.myfollower ) self.myfollower.moveInto( self.location );
  1848.     pass moveInto;
  1849.     }
  1850.     // these properties are for the format strings
  1851.     fmtYou = "he"
  1852.     fmtYour = "his"
  1853.     fmtYoure = "he's"
  1854.     fmtYoum = "him"
  1855.     fmtYouve = "he's"
  1856.     fmtS = "s"
  1857.     fmtEs = "es"
  1858.     fmtHave = "has"
  1859.     fmtDo = "does"
  1860.     fmtAre = "is"
  1861. ;
  1862.  
  1863. /*
  1864.  *  follower: Actor
  1865.  *
  1866.  *  This is a special object that can "shadow" the movements of a
  1867.  *  character as it moves from room to room.  The purpose of a follower
  1868.  *  is to allow the player to follow an actor as it leaves a room by
  1869.  *  typing a "follow" command.  Each actor that is to be followed must
  1870.  *  have its own follower object.  The follower object should
  1871.  *  define all of the same vocabulary words (nouns and adjectives) as the
  1872.  *  actual actor to which it refers.  The follower must also
  1873.  *  define the myactor property to be the Actor object that
  1874.  *  the follower follows.  The follower will always stay
  1875.  *  one room behind the character it follows; no commands are effective
  1876.  *  with a follower except for "follow."
  1877. */
  1878. class follower: Actor
  1879.     sdesc = { self.myactor.sdesc; }
  1880.     isfollower = true
  1881.     ldesc = { caps(); self.thedesc; " is no longer here. "; }
  1882.     actorAction( v, d, p, i ) = { self.ldesc; }
  1883.     actorDesc = {}
  1884.     myactor = nil   // set to the Actor to be followed
  1885.     verDoFollow( actor ) = {}
  1886.     doFollow( actor ) =
  1887.     {
  1888.         actor.travelTo( self.myactor.location );
  1889.     }
  1890. ;
  1891.  
  1892. /*
  1893.  *  basicMe: Actor
  1894.  *
  1895.  *  A default implementation of the Me object, which is the
  1896.  *  player character.  adv.t defines basicMe instead of
  1897.  *  Me to allow your game to override parts of the default
  1898.  *  implementation while still using the rest, and without changing
  1899.  *  adv.t itself.  To use basicMe unchanged as your player
  1900.  *  character, include this in your game:  "Me: basicMe;".
  1901.  *  
  1902.  *  The basicMe object defines all of the methods and properties
  1903.  *  required for an actor, with appropriate values for the player
  1904.  *  character.  The nouns "me" and "myself'' are defined ("I''
  1905.  *  is not defined, because it conflicts with the "inventory"
  1906.  *  command's minimal abbreviation of "i" in certain circumstances,
  1907.  *  and is generally not compatible with the syntax of most player
  1908.  *  commands anyway).  The sdesc is "you"; the thedesc
  1909.  *  and adesc are "yourself," which is appropriate for most
  1910.  *  contexts.  The maxbulk and maxweight properties are
  1911.  *  set to 10 each; a more sophisticated Me might include the
  1912.  *  player's state of health in determining the maxweight and
  1913.  *  maxbulk properties.
  1914. */
  1915. class basicMe: Actor
  1916.     roomCheck( v ) = { return( self.location.roomCheck( v )); }
  1917.     noun = 'me' 'myself'
  1918.     sdesc = "you"
  1919.     thedesc = "yourself"
  1920.     adesc = "yourself"
  1921.     ldesc = "You look about the same as always. "
  1922.     maxweight = 10
  1923.     maxbulk = 10
  1924.     verDoFollow( actor ) =
  1925.     {
  1926.         if ( actor = self ) "You can't follow yourself! ";
  1927.     }
  1928.     actorAction( verb, dobj, prep, iobj ) = 
  1929.     {
  1930.     }
  1931.     travelTo( room ) =
  1932.     {
  1933.         if ( room )
  1934.         {
  1935.         if ( room.isobstacle )
  1936.         {
  1937.             self.travelTo( room.destination );
  1938.         }
  1939.         else if ( not ( self.location.islit or room.islit ))
  1940.         {
  1941.             darkTravel();
  1942.         }
  1943.         else
  1944.         {
  1945.                 if ( self.location ) self.location.leaveRoom( self );
  1946.                 self.location := room;
  1947.                 room.enterRoom( self );
  1948.         }
  1949.         }
  1950.     }
  1951.     moveInto( room ) =
  1952.     {
  1953.         self.location := room;
  1954.     }
  1955.     // these properties are for the format strings
  1956.     fmtYou = "you"
  1957.     fmtYour = "your"
  1958.     fmtYoure = "you're"
  1959.     fmtYoum = "you"
  1960.     fmtYouve = "you've"
  1961.     fmtS = ""
  1962.     fmtEs = ""
  1963.     fmtHave = "have"
  1964.     fmtDo = "do"
  1965.     fmtAre = "are"
  1966. ;
  1967.  
  1968. /*
  1969.  *  decoration: fixeditem
  1970.  *
  1971.  *  An item that doesn't have any function in the game, apart from
  1972.  *  having been mentioned in the room description.  These items
  1973.  *  are immovable and can't be manipulated in any way, but can be
  1974.  *  referred to and inspected.  Liberal use of decoration items
  1975.  *  can improve a game's playability by helping the parser recognize
  1976.  *  all the words the game uses in its descriptions of rooms.
  1977. */
  1978. class decoration: fixeditem
  1979. ;
  1980.  
  1981. /*
  1982.  *  buttonitem: fixeditem
  1983.  *
  1984.  *  A button (the type you push).  The individual button's action method
  1985.  *  doPush(actor), which must be specified in
  1986.  *  the button, carries out the function of the button.  Note that
  1987.  *  all buttons have the noun "button" defined.
  1988. */
  1989. class buttonitem: fixeditem
  1990.     noun = 'button'
  1991.     plural = 'buttons'
  1992.     verDoPush( actor ) = {}
  1993. ;
  1994.  
  1995. /*
  1996.  *  clothingItem: item
  1997.  *
  1998.  *  Something that can be worn.  By default, the only thing that
  1999.  *  happens when the item is worn is that its isworn property
  2000.  *  is set to true.  If you want more to happen, override the
  2001.  *  doWear(actor) property.  Note that, when a clothingItem
  2002.  *  is being worn, certain operations will cause it to be removed (for
  2003.  *  example, dropping it causes it to be removed).  If you want
  2004.  *  something else to happen, override the checkDrop method;
  2005.  *  if you want to disallow such actions while the object is worn,
  2006.  *  use an exit statement in the checkDrop method.
  2007. */
  2008. class clothingItem: item
  2009.     checkDrop =
  2010.     {
  2011.         if ( self.isworn )
  2012.     {
  2013.         "(Taking off "; self.thedesc; " first)\n";
  2014.     }
  2015.     }
  2016.     doDrop( actor ) =
  2017.     {
  2018.         self.checkDrop;
  2019.     pass doDrop;
  2020.     }
  2021.     doPutIn( actor, io ) =
  2022.     {
  2023.         self.checkDrop;
  2024.     pass doPutIn;
  2025.     }
  2026.     doPutOn( actor, io ) =
  2027.     {
  2028.         self.checkDrop;
  2029.     pass doPutOn;
  2030.     }
  2031.     doGiveTo( actor, io ) =
  2032.     {
  2033.         self.checkDrop;
  2034.     pass doGiveTo;
  2035.     }
  2036.     doThrowAt( actor, io ) =
  2037.     {
  2038.         self.checkDrop;
  2039.     pass doThrowAt;
  2040.     }
  2041.     doThrowTo( actor, io ) =
  2042.     {
  2043.         self.checkDrop;
  2044.     pass doThrowTo;
  2045.     }
  2046.     doThrow( actor ) =
  2047.     {
  2048.         self.checkDrop;
  2049.     pass doThrow;
  2050.     }
  2051.     moveInto( obj ) =
  2052.     {
  2053.         /*
  2054.      *   Catch any other movements with moveInto; this won't stop the
  2055.      *   movement from happening, but it will prevent any anamolous
  2056.      *   consequences caused by the object moving but still being worn.
  2057.      */
  2058.         self.isworn := nil;
  2059.     pass moveInto;
  2060.     }
  2061.     verDoWear( actor ) =
  2062.     {
  2063.         if ( self.isworn )
  2064.         {
  2065.             "%You're% already wearing "; self.thedesc; "! ";
  2066.         }
  2067.         else if ( not actor.isCarrying( self ))
  2068.         {
  2069.             "%You% %do%n't have "; self.thedesc; ". ";
  2070.         }
  2071.     }
  2072.     doWear( actor ) =
  2073.     {
  2074.         "Okay, %you're% now wearing "; self.thedesc; ". ";
  2075.         self.isworn := true;
  2076.     }
  2077.     verDoUnwear( actor ) =
  2078.     {
  2079.         if ( not self.isworn )
  2080.         {
  2081.             "%You're% not wearing "; self.thedesc; ". ";
  2082.         }
  2083.     }
  2084.     doUnwear( actor ) =
  2085.     {
  2086.         "Okay, %you're% no longer wearing "; self.thedesc; ". ";
  2087.         self.isworn := nil;
  2088.     }
  2089. ;
  2090.  
  2091. /*
  2092.  *  obstacle: object
  2093.  *
  2094.  *  An obstacle is used in place of a room for a direction
  2095.  *  property.  The destination property specifies the room that
  2096.  *  is reached if the obstacle is successfully negotiated; when the
  2097.  *  obstacle is not successfully negotiated, destination should
  2098.  *  display an appropriate message and return nil.
  2099. */
  2100. class obstacle: object
  2101.     isobstacle = true
  2102. ;
  2103.  
  2104. /*
  2105.  *  doorway: fixeditem, obstacle
  2106.  *
  2107.  *  A doorway is an obstacle that impedes progress when it is closed.
  2108.  *  When the door is open (isopen is true), the user ends up in
  2109.  *  the room specified in the doordest property upon going through
  2110.  *  the door.  Since a doorway is an obstacle, use the door object for
  2111.  *  a direction property of the room containing the door.
  2112.  *  
  2113.  *  If noAutoOpen is not set to true, the door will automatically
  2114.  *  be opened when the player tries to walk through the door, unless the
  2115.  *  door is locked (islocked = true).  If the door is locked,
  2116.  *  it can be unlocked simply by typing "unlock door", unless the
  2117.  *  mykey property is set, in which case the object specified in
  2118.  *  mykey must be used to unlock the door.  Note that the door can
  2119.  *  only be relocked by the player under the circumstances that allow
  2120.  *  unlocking, plus the property islockable must be set to true.
  2121.  *  By default, the door is closed; set isopen to true if the door
  2122.  *  is to start out open (and be sure to open the other side as well).
  2123.  *  
  2124.  *  otherside specifies the corresponding doorway object in the
  2125.  *  destination room (doordest), if any.  If otherside is
  2126.  *  specified, its isopen and islocked properties will be
  2127.  *  kept in sync automatically.
  2128. */
  2129. class doorway: fixeditem, obstacle
  2130.     isdoor = true           // Item can be opened and closed
  2131.     destination =
  2132.     {
  2133.         if ( self.isopen ) return( self.doordest );
  2134.     else if ( not self.islocked and not self.noAutoOpen )
  2135.     {
  2136.         self.isopen := true;
  2137.         if ( self.otherside ) self.otherside.isopen := true;
  2138.         "(Opening << self.thedesc >>)\n";
  2139.         return( self.doordest );
  2140.     }
  2141.     else
  2142.     {
  2143.         "%You%'ll have to open << self.thedesc >> first. ";
  2144.         setit( self );
  2145.         return( nil );
  2146.     }
  2147.     }
  2148.     verDoOpen( actor ) =
  2149.     {
  2150.         if ( self.isopen ) "It's already open. ";
  2151.     else if ( self.islocked ) "It's locked. ";
  2152.     }
  2153.     doOpen( actor ) =
  2154.     {
  2155.         "Opened. ";
  2156.     self.isopen := true;
  2157.     if ( self.otherside ) self.otherside.isopen := true;
  2158.     }
  2159.     verDoClose( actor ) =
  2160.     {
  2161.         if ( not self.isopen ) "It's already closed. ";
  2162.     }
  2163.     doClose( actor ) =
  2164.     {
  2165.         "Closed. ";
  2166.     self.isopen := nil;
  2167.     if ( self.otherside ) self.otherside.isopen := nil;
  2168.     }
  2169.     verDoLock( actor ) =
  2170.     {
  2171.         if ( self.islocked ) "It's already locked! ";
  2172.     else if ( not self.islockable ) "It can't be locked. ";
  2173.     else if ( self.isopen ) "%You%'ll have to close it first. ";
  2174.     }
  2175.     doLock( actor ) =
  2176.     {
  2177.         if ( self.mykey = nil )
  2178.     {
  2179.         "Locked. ";
  2180.         self.islocked := true;
  2181.         if ( self.otherside ) self.otherside.islocked := true;
  2182.     }
  2183.     else
  2184.             askio( withPrep );
  2185.     }
  2186.     verDoUnlock( actor ) =
  2187.     {
  2188.         if ( not self.islocked ) "It's not locked! ";
  2189.     }
  2190.     doUnlock( actor ) =
  2191.     {
  2192.         if ( self.mykey = nil )
  2193.     {
  2194.         "Unlocked. ";
  2195.         self.islocked := nil;
  2196.         if ( self.otherside ) self.otherside.islocked := nil;
  2197.     }
  2198.     else
  2199.         askio( withPrep );
  2200.     }
  2201.     verDoLockWith( actor, io ) =
  2202.     {
  2203.         if ( self.islocked ) "It's already locked. ";
  2204.     else if ( not self.islockable ) "It can't be locked. ";
  2205.     else if ( self.mykey = nil )
  2206.         "%You% %do%n't need anything to lock it. ";
  2207.     else if ( self.isopen ) "%You%'ll have to close it first. ";
  2208.     }
  2209.     doLockWith( actor, io ) =
  2210.     {
  2211.         if ( io = self.mykey )
  2212.     {
  2213.         "Locked. ";
  2214.         self.islocked := true;
  2215.         if ( self.otherside ) self.otherside.islocked := true;
  2216.     }
  2217.     else "It doesn't fit the lock. ";
  2218.     }
  2219.     verDoUnlockWith( actor, io ) =
  2220.     {
  2221.         if ( not self.islocked ) "It's not locked! ";
  2222.     else if ( self.mykey = nil )
  2223.         "%You% %do%n't need anything to unlock it. ";
  2224.     }
  2225.     doUnlockWith( actor, io ) =
  2226.     {
  2227.         if ( io = self.mykey )
  2228.     {
  2229.         "Unlocked. ";
  2230.         self.islocked := nil;
  2231.         if ( self.otherside ) self.otherside.islocked := nil;
  2232.     }
  2233.     else "It doesn't fit the lock. ";
  2234.     }
  2235.     ldesc =
  2236.     {
  2237.     if ( self.isopen ) "It's open. ";
  2238.     else
  2239.     {
  2240.         if ( self.islocked ) "It's closed and locked. ";
  2241.         else "It's closed. ";
  2242.     }
  2243.     }
  2244. ;
  2245.  
  2246. /*
  2247.  *  lockableDoorway: doorway
  2248.  *
  2249.  *  This is just a normal doorway with the islockable and
  2250.  *  islocked properties set to true.  Fill in the other
  2251.  *  properties (otherside and doordest) as usual.  If
  2252.  *  the door has a key, set property mykey to the key object.
  2253. */
  2254. class lockableDoorway: doorway
  2255.     islockable = true
  2256.     islocked = true
  2257. ;
  2258.  
  2259. /*
  2260.  *  vehicle: item, nestedroom
  2261.  *
  2262.  *  This is an object that an actor can board.  An actor cannot go
  2263.  *  anywhere while on board a vehicle (except where the vehicle goes);
  2264.  *  the actor must get out first.
  2265. */
  2266. class vehicle: item, nestedroom
  2267.     reachable = ([] + self)
  2268.     isvehicle = true
  2269.     verDoEnter( actor ) = { self.verDoBoard( actor ); }
  2270.     doEnter( actor ) = { self.doBoard( actor ); }
  2271.     verDoBoard( actor ) =
  2272.     {
  2273.         if ( actor.location = self )
  2274.         {
  2275.             "%You're% already in "; self.thedesc; "! ";
  2276.         }
  2277.     }
  2278.     doBoard( actor ) =
  2279.     {
  2280.         "Okay, %you're% now in "; self.thedesc; ". ";
  2281.         actor.moveInto( self );
  2282.     }
  2283.     noexit =
  2284.     {
  2285.         "%You're% not going anywhere until %you% get%s% out of ";
  2286.       self.thedesc; ". ";
  2287.         return( nil );
  2288.     }
  2289.     out = ( self.location )
  2290. ;
  2291.  
  2292. /*
  2293.  *  surface: item
  2294.  *
  2295.  *  Objects can be placed on a surface.  Apart from using the
  2296.  *  preposition "on" rather than "in'' to refer to objects
  2297.  *  contained by the object, a surface is identical to a
  2298.  *  container.  Note: an object cannot be both a
  2299.  *  surface and a container, because there is no
  2300.  *  distinction between the two internally.
  2301. */
  2302. class surface: item
  2303.     issurface = true        // Item can hold objects on its surface
  2304.     ldesc =
  2305.     {
  2306.         if (itemcnt( self.contents ))
  2307.         {
  2308.             "On "; self.thedesc; " %you% see%s% "; listcont( self ); ". ";
  2309.         }
  2310.         else
  2311.         {
  2312.             "There's nothing on "; self.thedesc; ". ";
  2313.         }
  2314.     }
  2315.     verIoPutOn( actor ) = {}
  2316.     ioPutOn( actor, dobj ) =
  2317.     {
  2318.         dobj.doPutOn( actor, self );
  2319.     }
  2320. ;
  2321.  
  2322. /*
  2323.  *  container: item
  2324.  *
  2325.  *  This object can contain other objects.  The iscontainer property
  2326.  *  is set to true.  The default ldesc displays a list of the
  2327.  *  objects inside the container, if any.  The maxbulk property
  2328.  *  specifies the maximum amount of bulk the container can contain.
  2329. */
  2330. class container: item
  2331.     maxbulk = 10            // maximum bulk the container can contain
  2332.     isopen = true           // in fact, it can't be closed at all
  2333.     iscontainer = true      // Item can contain other items
  2334.     ldesc =
  2335.     {
  2336.         if ( self.contentsVisible and itemcnt( self.contents ) <> 0 )
  2337.         {
  2338.             "In "; self.thedesc; " %you% see%s% "; listcont( self ); ". ";
  2339.         }
  2340.         else
  2341.         {
  2342.             "There's nothing in "; self.thedesc; ". ";
  2343.         }
  2344.     }
  2345.     verIoPutIn( actor ) =
  2346.     {
  2347.     }
  2348.     ioPutIn( actor, dobj ) =
  2349.     {
  2350.         if (addbulk( self.contents ) + dobj.bulk > self.maxbulk )
  2351.         {
  2352.             "%You% can't fit that in "; self.thedesc; ". ";
  2353.         }
  2354.         else
  2355.         {
  2356.         dobj.doPutIn( actor, self );
  2357.         }
  2358.     }
  2359.     verDoLookin( actor ) = {}
  2360.     doLookin( actor ) =
  2361.     {
  2362.         self.ldesc;
  2363.     }
  2364. ;
  2365.  
  2366. /*
  2367.  *  openable: container
  2368.  *
  2369.  *  A container that can be opened and closed.  The isopenable
  2370.  *  property is set to true.  The default ldesc displays
  2371.  *  the contents of the container if the container is open, otherwise
  2372.  *  a message saying that the object is closed.
  2373. */
  2374. class openable: container
  2375.     contentsReachable = { return( self.isopen ); }
  2376.     contentsVisible = { return( self.isopen ); }
  2377.     isopenable = true
  2378.     ldesc =
  2379.     {
  2380.         caps(); self.thedesc;
  2381.         if ( self.isopen )
  2382.     {
  2383.         " is open. ";
  2384.         pass ldesc;
  2385.     }
  2386.         else " is closed. ";
  2387.     }
  2388.     isopen = true
  2389.     verDoOpen( actor ) =
  2390.     {
  2391.         if ( self.isopen )
  2392.     {
  2393.         caps(); self.thedesc; " is already open! ";
  2394.     }
  2395.     }
  2396.     doOpen( actor ) =
  2397.     {
  2398.         if (itemcnt( self.contents ))
  2399.     {
  2400.         "Opening "; self.thedesc; " reveals "; listcont( self ); ". ";
  2401.     }
  2402.     else "Opened. ";
  2403.     self.isopen := true;
  2404.     }
  2405.     verDoClose( actor ) =
  2406.     {
  2407.         if ( not self.isopen )
  2408.     {
  2409.         caps(); self.thedesc; " is already closed! ";
  2410.     }
  2411.     }
  2412.     doClose( actor ) =
  2413.     {
  2414.         "Closed. ";
  2415.     self.isopen := nil;
  2416.     }
  2417.     verIoPutIn( actor ) =
  2418.     {
  2419.         if ( not self.isopen )
  2420.     {
  2421.         caps(); self.thedesc; " is closed. ";
  2422.     }
  2423.     }
  2424.     verDoLookin( actor ) =
  2425.     {
  2426.         if ( not self.isopen ) "It's closed. ";
  2427.     }
  2428. ;
  2429.  
  2430. /*
  2431.  *  qcontainer: container
  2432.  *
  2433.  *  A "quiet" container:  its contents are not listed when it shows
  2434.  *  up in a room description or inventory list.  The isqcontainer
  2435.  *  property is set to true.
  2436. */
  2437. class qcontainer: container
  2438.     isqcontainer = true
  2439. ;
  2440.  
  2441. /*
  2442.  *  lockable: openable
  2443.  *
  2444.  *  A container that can be locked and unlocked.  The islocked
  2445.  *  property specifies whether the object can be opened or not.  The
  2446.  *  object can be locked and unlocked without the need for any other
  2447.  *  object; if you want a key to be involved, use a keyedLockable.
  2448. */
  2449. class lockable: openable
  2450.     doOpen( actor ) =
  2451.     {
  2452.         if ( self.islocked )
  2453.         {
  2454.             "It's locked. ";
  2455.         }
  2456.         else pass doOpen;
  2457.     }
  2458.     verDoLock( actor ) =
  2459.     {
  2460.         if ( self.islocked )
  2461.         {
  2462.             "It's already locked! ";
  2463.         }
  2464.     }
  2465.     doLock( actor ) =
  2466.     {
  2467.         if ( self.isopen )
  2468.         {
  2469.             "%You%'ll have to close "; self.thedesc; " first. ";
  2470.         }
  2471.         else
  2472.         {
  2473.             "Locked. ";
  2474.             self.islocked := true;
  2475.         }
  2476.     }
  2477.     verDoUnlock( actor ) =
  2478.     {
  2479.         if ( not self.islocked ) "It's not locked! ";
  2480.     }
  2481.     doUnlock( actor ) =
  2482.     {
  2483.         "Unlocked. ";
  2484.         self.islocked := nil;
  2485.     }
  2486.     verDoLockWith( actor, io ) =
  2487.     {
  2488.         if ( self.islocked ) "It's already locked. ";
  2489.     }
  2490.     verDoUnlockWith( actor, io ) =
  2491.     {
  2492.         if ( not self.islocked ) "It's not locked! ";
  2493.     }
  2494. ;
  2495.  
  2496. /*
  2497.  *  keyedLockable: lockable
  2498.  *
  2499.  *  This subclass of lockable allows you to create an object
  2500.  *  that can only be locked and unlocked with a corresponding key.
  2501.  *  Set the property mykey to the keyItem object that can
  2502.  *  lock and unlock the object.
  2503. */
  2504. class keyedLockable: lockable
  2505.     mykey = nil     // set 'mykey' to the key which locks/unlocks me
  2506.     doLock( actor ) =
  2507.     {
  2508.         askio( withPrep );
  2509.     }
  2510.     doUnlock( actor ) =
  2511.     {
  2512.         askio( withPrep );
  2513.     }
  2514.     doLockWith( actor, io ) =
  2515.     {
  2516.         if ( self.isopen )
  2517.         {
  2518.             "%You% can't lock << self.thedesc >> when it's open. ";
  2519.         }
  2520.         else if ( io = self.mykey )
  2521.         {
  2522.             "Locked. ";
  2523.             self.islocked := true;
  2524.         }
  2525.         else "It doesn't fit the lock. ";
  2526.     }
  2527.     doUnlockWith( actor, io ) =
  2528.     {
  2529.         if ( io = self.mykey )
  2530.         {
  2531.             "Unlocked. ";
  2532.             self.islocked := nil;
  2533.         }
  2534.         else "It doesn't fit the lock. ";
  2535.     }
  2536. ;
  2537.  
  2538. /*
  2539.  *  keyItem: item
  2540.  *
  2541.  *  This is an object that can be used as a key for a keyedLockable
  2542.  *  or lockableDoorway object.  It otherwise behaves as an ordinary item.
  2543. */
  2544. class keyItem: item
  2545.     verIoUnlockWith( actor ) = {}
  2546.     ioUnlockWith( actor, dobj ) =
  2547.     {
  2548.         dobj.doUnlockWith( actor, self );
  2549.     }
  2550.     verIoLockWith( actor ) = {}
  2551.     ioLockWith( actor, dobj ) =
  2552.     {
  2553.         dobj.doLockWith( actor, self );
  2554.     }
  2555. ;
  2556.  
  2557. /*
  2558.  *  transparentItem: item
  2559.  *
  2560.  *  An object whose contents are visible, even when the object is
  2561.  *  closed.  Whether the contents are reachable is decided in the
  2562.  *  normal fashion.  This class is useful for items such as glass
  2563.  *  bottles, whose contents can be seen when the bottle is closed
  2564.  *  but cannot be reached.
  2565. */
  2566. class transparentItem: item
  2567.     contentsVisible = { return( true ); }
  2568.     verGrab( obj ) =
  2569.     {
  2570.         if ( self.isopenable and not self.isopen )
  2571.             "%You% will have to open << self.thedesc >> first. ";
  2572.     }
  2573.     doOpen( actor ) =
  2574.     {
  2575.         self.isopen := true;
  2576.         "Opened. ";
  2577.     }
  2578. ;
  2579.  
  2580. /*
  2581.  *  basicNumObj: object
  2582.  *
  2583.  *  This object provides a default implementation for numObj.
  2584.  *  To use this default unchanged in your game, include in your
  2585.  *  game this line:  "numObj: basicNumObj".
  2586. */
  2587. class basicNumObj: object   // when a number is used in a player command,
  2588.     value = 0               //  this is set to its value
  2589.     sdesc = "that"
  2590.     adesc = "that"
  2591.     thedesc = "that"
  2592.     verDoTypeOn( actor, io ) = {}
  2593.     doTypeOn( actor, io ) = { "\"Tap, tap, tap, tap...\" "; }
  2594.     verIoTurnTo( actor ) = {}
  2595.     ioTurnTo( actor, dobj ) = { dobj.doTurnTo( actor, self ); }
  2596. ;
  2597.  
  2598. /*
  2599.  *  basicStrObj: object
  2600.  *
  2601.  *  This object provides a default implementation for strObj.
  2602.  *  To use this default unchanged in your game, include in your
  2603.  *  game this line:  "strObj: basicStrObj".
  2604. */
  2605. class basicStrObj: object   // when a string is used in a player command,
  2606.     value = ''              //  this is set to its value
  2607.     sdesc = "that"
  2608.     adesc = "that"
  2609.     thedesc = "that"
  2610.     verDoTypeOn( actor, io ) = {}
  2611.     doTypeOn( actor, io ) = { "\"Tap, tap, tap, tap...\" "; }
  2612.     verDoSave( actor ) = {}
  2613.     doSave( actor ) =
  2614.     {
  2615.         if (save( self.value ))
  2616.             "Save failed. ";
  2617.         else
  2618.             "Saved. ";
  2619.     abort;
  2620.     }
  2621.     verDoRestore( actor ) = {}
  2622.     doRestore( actor ) =
  2623.     {
  2624.         if (restore( self.value ))
  2625.             "Restore failed. ";
  2626.         else
  2627.     {
  2628.             "Restored. ";
  2629.         setscore( global.score, global.turnsofar );
  2630.     }
  2631.         abort;
  2632.     }
  2633.     verDoScript( actor ) = {}
  2634.     doScript( actor ) =
  2635.     {
  2636.         logging( self.value );
  2637.         "Writing script file. ";
  2638.         abort;
  2639.     }
  2640.     verDoSay( actor ) = {}
  2641.     doSay( actor ) =
  2642.     {
  2643.         "Okay, \""; say( self.value ); "\".";
  2644.     }
  2645. ;
  2646.  
  2647. /*
  2648.  *  deepverb: object
  2649.  *
  2650.  *  A "verb object" that is referenced by the parser when the player
  2651.  *  uses an associated vocabulary word.  A deepverb contains both
  2652.  *  the vocabulary of the verb and a description of available syntax.
  2653.  *  The verb property lists the verb vocabulary words;
  2654.  *  one word (such as 'take') or a pair (such as 'pick up')
  2655.  *  can be used.  In the latter case, the second word must be a
  2656.  *  preposition, and may move to the end of the sentence in a player's
  2657.  *  command, as in "pick it up."  The action(actor)
  2658.  *  method specifies what happens when the verb is used without any
  2659.  *  objects; its absence specifies that the verb cannot be used without
  2660.  *  an object.  The doAction specifies the root of the message
  2661.  *  names (in single quotes) sent to the direct object when the verb
  2662.  *  is used with a direct object; its absence means that a single object
  2663.  *  is not allowed.  Likewise, the ioAction(preposition)
  2664.  *  specifies the root of the message name sent to the direct and
  2665.  *  indirect objects when the verb is used with both a direct and
  2666.  *  indirect object; its absence means that this syntax is illegal.
  2667.  *  Several ioAction properties may be present:  one for each
  2668.  *  preposition that can be used with an indirect object with the verb.
  2669.  *  
  2670.  *  The validDo(actor, object, seqno) method returns true
  2671.  *  if the indicated object is valid as a direct object for this actor.
  2672.  *  The validIo(actor, object, seqno) method does likewise
  2673.  *  for indirect objects.  The seqno parameter is a "sequence
  2674.  *  number," starting with 1 for the first object tried for a given
  2675.  *  verb, 2 for the second, and so forth; this parameter is normally
  2676.  *  ignored, but can be used for some special purposes.  For example,
  2677.  *  askVerb does not distinguish between objects matching vocabulary
  2678.  *  words, and therefore accepts only the first from a set of ambiguous
  2679.  *  objects.  These methods do not normally need to be changed; by
  2680.  *  default, they return true if the object is accessible to the
  2681.  *  actor.
  2682.  *  
  2683.  *  The doDefault(actor, prep, indirectObject) and
  2684.  *  ioDefault(actor, prep) methods return a list of the
  2685.  *  default direct and indirect objects, respectively.  These lists
  2686.  *  are used for determining which objects are meant by "all" and which
  2687.  *  should be used when the player command is missing an object.  These
  2688.  *  normally return a list of all objects that are applicable to the
  2689.  *  current command.
  2690. */
  2691. class deepverb: object                // A deep-structure verb.
  2692.     validDo( actor, obj, seqno ) =
  2693.     {
  2694.         return( obj.isReachable( actor ));
  2695.     }
  2696.     invalidObj( actor, obj, name ) =
  2697.     {
  2698.         if ( not obj.isVisible( actor ))
  2699.             "I don't see any << name >> here. ";
  2700.         else
  2701.             "%You% can't do that with << obj.thedesc >>. ";
  2702.     }
  2703.     validIo( actor, obj, seqno ) =
  2704.     {
  2705.         return( obj.isReachable( actor ));
  2706.     }
  2707.     doDefault( actor, prep, io ) =
  2708.     {
  2709.         return( actor.contents + actor.location.contents );
  2710.     }
  2711.     ioDefault( actor, prep ) =
  2712.     {
  2713.         return( actor.contents + actor.location.contents );
  2714.     }
  2715. ;
  2716.  
  2717. /*
  2718.  *   Various verbs.
  2719.  */
  2720. inspectVerb: deepverb
  2721.     verb = 'inspect' 'examine' 'look at' 'x'
  2722.     sdesc = "inspect"
  2723.     doAction = 'Inspect'
  2724.     validDo( actor, obj, seqno ) =
  2725.     {
  2726.         return( obj.isVisible( actor ));
  2727.     }
  2728. ;
  2729. askVerb: deepverb
  2730.     verb = 'ask'
  2731.     sdesc = "ask"
  2732.     prepDefault = aboutPrep
  2733.     ioAction( aboutPrep ) = 'AskAbout'
  2734.     validIo( actor, obj, seqno ) = { return( seqno = 1 ); }
  2735. ;
  2736. tellVerb: deepverb
  2737.     verb = 'tell'
  2738.     sdesc = "tell"
  2739.     prepDefault = aboutPrep
  2740.     ioAction( aboutPrep ) = 'TellAbout'
  2741.     validIo( actor, obj, seqno ) = { return( seqno = 1 ); }
  2742. ;
  2743. followVerb: deepverb
  2744.     sdesc = "follow"
  2745.     verb = 'follow'
  2746.     doAction = 'Follow'
  2747. ;
  2748. digVerb: deepverb
  2749.     verb = 'dig' 'dig in'
  2750.     sdesc = "dig in"
  2751.     prepDefault = withPrep
  2752.     ioAction( withPrep ) = 'DigWith'
  2753. ;
  2754. jumpVerb: deepverb
  2755.     verb = 'jump' 'jump over' 'jump off'
  2756.     doAction = 'Jump'
  2757.     action(actor) = { "Wheeee!"; }
  2758. ;
  2759. pushVerb: deepverb
  2760.     verb = 'push' 'press'
  2761.     sdesc = "push"
  2762.     doAction = 'Push'
  2763. ;
  2764. attachVerb: deepverb
  2765.     verb = 'attach' 'connect'
  2766.     sdesc = "attach"
  2767.     prepDefault = toPrep
  2768.     ioAction( toPrep ) = 'AttachTo'
  2769. ;
  2770. wearVerb: deepverb
  2771.     verb = 'wear' 'put on'
  2772.     sdesc = "wear"
  2773.     doAction = 'Wear'
  2774. ;
  2775. dropVerb: deepverb
  2776.     verb = 'drop' 'put down'
  2777.     sdesc = "drop"
  2778.     ioAction( onPrep ) = 'PutOn'
  2779.     doAction = 'Drop'
  2780.     doDefault( actor, prep, io ) =
  2781.     {
  2782.         return( actor.contents );
  2783.     }
  2784. ;
  2785. removeVerb: deepverb
  2786.     verb = 'take off'
  2787.     sdesc = "take off"
  2788.     doAction = 'Unwear'
  2789.     ioAction( fromPrep ) = 'RemoveFrom'
  2790. ;
  2791. openVerb: deepverb
  2792.     verb = 'open'
  2793.     sdesc = "open"
  2794.     doAction = 'Open'
  2795. ;
  2796. closeVerb: deepverb
  2797.     verb = 'close'
  2798.     sdesc = "close"
  2799.     doAction = 'Close'
  2800. ;
  2801. putVerb: deepverb
  2802.     verb = 'put' 'place'
  2803.     sdesc = "put"
  2804.     prepDefault = inPrep
  2805.     ioAction( inPrep ) = 'PutIn'
  2806.     ioAction( onPrep ) = 'PutOn'
  2807.     doDefault( actor, prep, io ) =
  2808.     {
  2809.         return( takeVerb.doDefault( actor, prep, io ) + actor.contents );
  2810.     }
  2811. ;
  2812. takeVerb: deepverb                   // This object defines how to take things
  2813.     verb = 'take' 'pick up' 'get' 'remove'
  2814.     sdesc = "take"
  2815.     ioAction( offPrep ) = 'TakeOff'
  2816.     ioAction( outPrep ) = 'TakeOut'
  2817.     ioAction( fromPrep ) = 'TakeOut'
  2818.     ioAction( inPrep ) = 'TakeOut'
  2819.     ioAction( onPrep ) = 'TakeOff'
  2820.     doAction = 'Take'
  2821.     doDefault( actor, prep, io ) =
  2822.     {
  2823.         local ret, rem, cur, rem2, cur2, tot, i, tot2, j;
  2824.     
  2825.     ret := [];
  2826.         
  2827.     /*
  2828.      *   For "take all out/off of <iobj>", return the (non-fixed)
  2829.      *   contents of the indirect object.  Same goes for "take all in
  2830.      *   <iobj>", "take all on <iobj>", and "take all from <iobj>".
  2831.      */
  2832.     if (( prep=outPrep or prep=offPrep or prep=inPrep or prep=onPrep
  2833.      or prep=fromPrep ) and io<>nil )
  2834.     {
  2835.         rem := io.contents;
  2836.         i := 1;
  2837.         tot := length( rem );
  2838.         while ( i <= tot )
  2839.         {
  2840.             cur := rem[i];
  2841.             if ( not cur.isfixed ) ret := ret + cur;
  2842.         i := i + 1;
  2843.         }
  2844.             return( ret );
  2845.     }
  2846.  
  2847.         /*
  2848.      *   In the general case, return everything that's not fixed
  2849.      *   in the actor's location, or everything inside fixed containers
  2850.      *   that isn't itself fixed.
  2851.      */
  2852.         rem := actor.location.contents;
  2853.     tot := length( rem );
  2854.     i := 1;
  2855.         while ( i <= tot )
  2856.         {
  2857.         cur := rem[i];
  2858.             if ( cur.isfixed )
  2859.             {
  2860.                 if ((( cur.isopenable and cur.isopen ) or
  2861.                   ( not cur.isopenable )) and ( not cur.isactor ))
  2862.                 {
  2863.                     rem2 := cur.contents;
  2864.             tot2 := length( rem2 );
  2865.             j := 1;
  2866.                     while ( j <= tot2 )
  2867.                     {
  2868.                 cur2 := rem2[j];
  2869.                         if ( not cur2.isfixed and not cur2.notakeall )
  2870.             {
  2871.                 ret := ret + cur2;
  2872.             }
  2873.                         j := j + 1;
  2874.                     }
  2875.                 }
  2876.             }
  2877.             else if ( not cur.notakeall )
  2878.         {
  2879.             ret := ret + cur;
  2880.         }
  2881.  
  2882.         i := i + 1;            
  2883.         }
  2884.         return( ret );
  2885.     }
  2886. ;
  2887. plugVerb: deepverb
  2888.     verb = 'plug'
  2889.     sdesc = "plug"
  2890.     prepDefault = inPrep
  2891.     ioAction( inPrep ) = 'PlugIn'
  2892. ;
  2893. lookInVerb: deepverb
  2894.     verb = 'look in' 'look on'
  2895.     sdesc = "look in"
  2896.     doAction = 'Lookin'
  2897. ;
  2898. screwVerb: deepverb
  2899.     verb = 'screw'
  2900.     sdesc = "screw"
  2901.     ioAction( withPrep ) = 'ScrewWith'
  2902.     doAction = 'Screw'
  2903. ;
  2904. unscrewVerb: deepverb
  2905.     verb = 'unscrew'
  2906.     sdesc = "unscrew"
  2907.     ioAction( withPrep ) = 'UnscrewWith'
  2908.     doAction = 'Unscrew'
  2909. ;
  2910. turnVerb: deepverb
  2911.     verb = 'turn' 'rotate' 'twist'
  2912.     sdesc = "turn"
  2913.     ioAction( toPrep ) = 'TurnTo'
  2914.     ioAction( withPrep ) = 'TurnWith'
  2915.     doAction = 'Turn'
  2916. ;
  2917. switchVerb: deepverb
  2918.     verb = 'switch'
  2919.     sdesc = "switch"
  2920.     doAction = 'Switch'
  2921. ;
  2922. flipVerb: deepverb
  2923.     verb = 'flip'
  2924.     sdesc = "flip"
  2925.     doAction = 'Flip'
  2926. ;
  2927. turnOnVerb: deepverb
  2928.     verb = 'activate' 'turn on' 'switch on'
  2929.     sdesc = "turn on"
  2930.     doAction = 'Turnon'
  2931. ;
  2932. turnOffVerb: deepverb
  2933.     verb = 'turn off' 'deactiv' 'switch off'
  2934.     sdesc = "turn off"
  2935.     doAction = 'Turnoff'
  2936. ;
  2937. lookVerb: deepverb
  2938.     verb = 'look' 'l' 'look around'
  2939.     action( actor ) =
  2940.     {
  2941.         actor.location.lookAround( true );
  2942.     }
  2943. ;
  2944. sitVerb: deepverb
  2945.     verb = 'sit on' 'sit in' 'sit' 'sit down' 'sit downin' 'sit downon'
  2946.     sdesc = "sit on"
  2947.     doAction = 'Siton'
  2948. ;
  2949. lieVerb: deepverb
  2950.     verb = 'lie' 'lie on' 'lie in' 'lie down' 'lie downon' 'lie downin'
  2951.     sdesc = "lie on"
  2952.     doAction = 'Lieon'
  2953. ;
  2954. getOutVerb: deepverb
  2955.     verb = 'get out' 'get outof' 'get off' 'get offof'
  2956.     sdesc = "get out of"
  2957.     doAction = 'Unboard'
  2958.     doDefault( actor, prep, io ) =
  2959.     {
  2960.         if ( actor.location and actor.location.location )
  2961.             return( [] + actor.location );
  2962.         else return( [] );
  2963.     }
  2964. ;
  2965. boardVerb: deepverb
  2966.     verb = 'get in' 'get into' 'board' 'get on'
  2967.     sdesc = "get on"
  2968.     doAction = 'Board'
  2969. ;
  2970. againVerb: deepverb         // Required verb:  repeats last command.  No
  2971.                             // action routines are necessary; this one's
  2972.                             // handled internally by the parser.
  2973.     verb = 'again' 'g'
  2974. ;
  2975. waitVerb: deepverb
  2976.     verb = 'wait' 'z'
  2977.     action( actor ) =
  2978.     {
  2979.         "Time passes...\n";
  2980.     }
  2981. ;
  2982. iVerb: deepverb
  2983.     verb = 'inventory' 'i'
  2984.     action( actor ) =
  2985.     {
  2986.         if (length( actor.contents ))
  2987.         {
  2988.             "%You% %have% "; listcont( actor ); ". ";
  2989.             listcontcont( actor );
  2990.         }
  2991.     else
  2992.             "%You% %are% empty-handed.\n";
  2993.     }
  2994. ;
  2995. lookThruVerb: deepverb
  2996.     verb = 'look through' 'look thru'
  2997.     sdesc = "look through"
  2998.     doAction = 'Lookthru'
  2999. ;
  3000. attackVerb: deepverb
  3001.     verb = 'attack' 'kill' 'hit'
  3002.     sdesc = "attack"
  3003.     prepDefault = withPrep
  3004.     ioAction( withPrep ) = 'AttackWith'
  3005. ;
  3006. climbVerb: deepverb
  3007.     verb = 'climb'
  3008.     sdesc = "climb"
  3009.     doAction = 'Climb'
  3010. ;
  3011. eatVerb: deepverb
  3012.     verb = 'eat' 'consume'
  3013.     sdesc = "eat"
  3014.     doAction = 'Eat'
  3015. ;
  3016. drinkVerb: deepverb
  3017.     verb = 'drink'
  3018.     sdesc = "drink"
  3019.     doAction = 'Drink'
  3020. ;
  3021. giveVerb: deepverb
  3022.     verb = 'give' 'offer'
  3023.     sdesc = "give"
  3024.     prepDefault = toPrep
  3025.     ioAction( toPrep ) = 'GiveTo'
  3026. ;
  3027. pullVerb: deepverb
  3028.     verb = 'pull'
  3029.     sdesc = "pull"
  3030.     doAction = 'Pull'
  3031. ;
  3032. readVerb: deepverb
  3033.     verb = 'read'
  3034.     sdesc = "read"
  3035.     doAction = 'Read'
  3036. ;
  3037. throwVerb: deepverb
  3038.     verb = 'throw' 'toss'
  3039.     sdesc = "throw"
  3040.     prepDefault = atPrep
  3041.     ioAction( atPrep ) = 'ThrowAt'
  3042.     ioAction( toPrep ) = 'ThrowTo'
  3043. ;
  3044. standOnVerb: deepverb
  3045.     verb = 'stand on'
  3046.     sdesc = "stand on"
  3047.     doAction = 'Standon'
  3048. ;
  3049. standVerb: deepverb
  3050.     verb = 'stand' 'stand up' 'get up'
  3051.     sdesc = "stand"
  3052.     action( actor ) =
  3053.     {
  3054.         if ( actor.location=nil or actor.location.location = nil )
  3055.             "%You're% already standing! ";
  3056.         else
  3057.         {
  3058.         actor.location.doUnboard( actor );
  3059.         }
  3060.     }
  3061. ;
  3062. helloVerb: deepverb
  3063.     verb = 'hello' 'hi' 'greetings'
  3064.     action( actor ) =
  3065.     {
  3066.         "Nice weather we've been having.\n";
  3067.     }
  3068. ;
  3069. showVerb: deepverb
  3070.     verb = 'show'
  3071.     sdesc = "show"
  3072.     prepDefault = toPrep
  3073.     ioAction( toPrep ) = 'ShowTo'
  3074. ;
  3075. cleanVerb: deepverb
  3076.     verb = 'clean'
  3077.     sdesc = "clean"
  3078.     ioAction( withPrep ) = 'CleanWith'
  3079.     doAction = 'Clean'
  3080. ;
  3081. sayVerb: deepverb
  3082.     verb = 'say'
  3083.     sdesc = "say"
  3084.     doAction = 'Say'
  3085. ;
  3086. yellVerb: deepverb
  3087.     verb = 'yell' 'shout' 'yell at' 'shout at'
  3088.     action( actor ) =
  3089.     {
  3090.         "%Your% throat is a bit sore now. ";
  3091.     }
  3092. ;
  3093. moveVerb: deepverb
  3094.     verb = 'move'
  3095.     sdesc = "move"
  3096.     ioAction( withPrep ) = 'MoveWith'
  3097.     ioAction( toPrep ) = 'MoveTo'
  3098.     doAction = 'Move'
  3099. ;
  3100. fastenVerb: deepverb
  3101.     verb = 'fasten' 'buckle' 'buckle up'
  3102.     sdesc = "fasten"
  3103.     doAction = 'Fasten'
  3104. ;
  3105. unfastenVerb: deepverb
  3106.     verb = 'unfasten' 'unbuckle'
  3107.     sdesc = "unfasten"
  3108.     doAction = 'Unfasten'
  3109. ;
  3110. unplugVerb: deepverb
  3111.     verb = 'unplug'
  3112.     sdesc = "unplug"
  3113.     ioAction( fromPrep ) = 'UnplugFrom'
  3114.     doAction = 'Unplug'
  3115. ;
  3116. lookUnderVerb: deepverb
  3117.     verb = 'look under' 'look beneath'
  3118.     sdesc = "look under"
  3119.     doAction = 'Lookunder'
  3120. ;
  3121. lookBehindVerb: deepverb
  3122.     verb = 'look behind'
  3123.     sdesc = "look behind"
  3124.     doAction = 'Lookbehind'
  3125. ;
  3126. typeVerb: deepverb
  3127.     verb = 'type'
  3128.     sdesc = "type"
  3129.     prepDefault = onPrep
  3130.     ioAction( onPrep ) = 'TypeOn'
  3131. ;
  3132. lockVerb: deepverb
  3133.     verb = 'lock'
  3134.     sdesc = "lock"
  3135.     ioAction( withPrep ) = 'LockWith'
  3136.     doAction = 'Lock'
  3137.     prepDefault = withPrep
  3138. ;
  3139. unlockVerb: deepverb
  3140.     verb = 'unlock'
  3141.     sdesc = "unlock"
  3142.     ioAction( withPrep ) = 'UnlockWith'
  3143.     doAction = 'Unlock'
  3144.     prepDefault = withPrep
  3145. ;
  3146. detachVerb: deepverb
  3147.     verb = 'detach' 'disconnect'
  3148.     prepDefault = fromPrep
  3149.     ioAction( fromPrep ) = 'DetachFrom'
  3150.     doAction = 'Detach'
  3151.     sdesc = "detach"
  3152. ;
  3153. sleepVerb: deepverb
  3154.     action( actor ) =
  3155.     {
  3156.         if ( actor.cantSleep )
  3157.             "%You% %are% much too anxious worrying about %your% continued
  3158.             survival to fall asleep now. ";
  3159.         else if ( global.awakeTime+1 < global.sleepTime )
  3160.             "%You're% not tired. ";
  3161.         else if ( not ( actor.location.isbed or actor.location.ischair ))
  3162.             "I don't know about you, but I can never sleep
  3163.             standing up. %You% should find a nice comfortable
  3164.             bed somewhere. ";
  3165.         else
  3166.         {
  3167.             "%You% quickly drift%s% off into dreamland...\b";
  3168.             goToSleep();
  3169.         }
  3170.     }
  3171.     verb = 'sleep'
  3172. ;
  3173. pokeVerb: deepverb
  3174.     verb = 'poke' 'jab'
  3175.     sdesc = "poke"
  3176.     doAction = 'Poke'
  3177. ;
  3178. touchVerb: deepverb
  3179.     verb = 'touch'
  3180.     sdesc = "touch"
  3181.     doAction = 'Touch'
  3182. ;
  3183. moveNVerb: deepverb
  3184.     verb = 'move north' 'move n' 'push north' 'push n'
  3185.     sdesc = "move north"
  3186.     doAction = 'MoveN'
  3187. ;
  3188. moveSVerb: deepverb
  3189.     verb = 'move south' 'move s' 'push south' 'push s'
  3190.     sdesc = "move south"
  3191.     doAction = 'MoveS'
  3192. ;
  3193. moveEVerb: deepverb
  3194.     verb = 'move east' 'move e' 'push east' 'push e'
  3195.     sdesc = "move east"
  3196.     doAction = 'MoveE'
  3197. ;
  3198. moveWVerb: deepverb
  3199.     verb = 'move west' 'move w' 'push west' 'push w'
  3200.     sdesc = "move west"
  3201.     doAction = 'MoveW'
  3202. ;
  3203. moveNEVerb: deepverb
  3204.     verb = 'move northeast' 'move ne' 'push northeast' 'push ne'
  3205.     sdesc = "move northeast"
  3206.     doAction = 'MoveNE'
  3207. ;
  3208. moveNWVerb: deepverb
  3209.     verb = 'move northwest' 'move nw' 'push northwest' 'push nw'
  3210.     sdesc = "move northwest"
  3211.     doAction = 'MoveNW'
  3212. ;
  3213. moveSEVerb: deepverb
  3214.     verb = 'move southeast' 'move se' 'push southeast' 'push se'
  3215.     sdesc = "move southeast"
  3216.     doAction = 'MoveSE'
  3217. ;
  3218. moveSWVerb: deepverb
  3219.     verb = 'move southwest' 'move sw' 'push southwest' 'push sw'
  3220.     sdesc = "move southwest"
  3221.     doAction = 'MoveSW'
  3222. ;
  3223. centerVerb: deepverb
  3224.     verb = 'center'
  3225.     sdesc = "center"
  3226.     doAction = 'Center'
  3227. ;
  3228. searchVerb: deepverb
  3229.     verb = 'search'
  3230.     sdesc = "search"
  3231.     doAction = 'Search'
  3232. ;
  3233.  
  3234. /*
  3235.  *   Travel verbs  - these verbs allow the player to move about.
  3236.  *   All travel verbs have the property isTravelVerb set true.
  3237.  */
  3238. class travelVerb: deepverb
  3239.     isTravelVerb = true
  3240. ;
  3241. eVerb: travelVerb
  3242.     action( actor ) = { actor.travelTo( self.travelDir( actor )); }
  3243.     verb = 'e' 'east' 'go east'
  3244.     travelDir( actor ) = { return( actor.location.east ); }
  3245. ;
  3246. sVerb: travelVerb
  3247.     action( actor ) = { actor.travelTo( self.travelDir( actor )); }
  3248.     verb = 's' 'south' 'go south'
  3249.     travelDir( actor ) = { return( actor.location.south ); }
  3250. ;
  3251. nVerb: travelVerb
  3252.     action( actor ) = { actor.travelTo( self.travelDir( actor )); }
  3253.     verb = 'n' 'north' 'go north'
  3254.     travelDir( actor ) = { return( actor.location.north ); }
  3255. ;
  3256. wVerb: travelVerb
  3257.     action( actor ) = { actor.travelTo( self.travelDir( actor )); }
  3258.     verb = 'w' 'west' 'go west'
  3259.     travelDir( actor ) = { return( actor.location.west ); }
  3260. ;
  3261. neVerb: travelVerb
  3262.     action( actor ) = { actor.travelTo( self.travelDir( actor )); }
  3263.     verb = 'ne' 'northeast' 'go ne' 'go northeast'
  3264.     travelDir( actor ) = { return( actor.location.ne ); }
  3265. ;
  3266. nwVerb: travelVerb
  3267.     action( actor ) = { actor.travelTo( self.travelDir( actor )); }
  3268.     verb = 'nw' 'northwest' 'go nw' 'go northwest'
  3269.     travelDir( actor ) = { return( actor.location.nw ); }
  3270. ;
  3271. seVerb: travelVerb
  3272.     action( actor ) = { actor.travelTo( self.travelDir( actor )); }
  3273.     verb = 'se' 'southeast' 'go se' 'go southeast'
  3274.     travelDir( actor ) = { return( actor.location.se ); }
  3275. ;
  3276. swVerb: travelVerb
  3277.     action( actor ) = { actor.travelTo( self.travelDir( actor )); }
  3278.     verb = 'sw' 'southwest' 'go sw' 'go southwest'
  3279.     travelDir( actor ) = { return( actor.location.sw ); }
  3280. ;
  3281. inVerb: travelVerb
  3282.     action( actor ) = { actor.travelTo( self.travelDir( actor )); }
  3283.     verb = 'in' 'go in' 'enter'
  3284.     sdesc = "enter"
  3285.     doAction = 'Enter'
  3286.     travelDir( actor ) = { return( actor.location.in ); }
  3287. ;
  3288. outVerb: travelVerb
  3289.     action( actor ) = { actor.travelTo( self.travelDir( actor )); }
  3290.     verb = 'out' 'go out' 'exit' 'leave'
  3291.     travelDir( actor ) = { return( actor.location.out ); }
  3292. ;
  3293. dVerb: travelVerb
  3294.     action( actor ) = { actor.travelTo( self.travelDir( actor )); }
  3295.     verb = 'd' 'down' 'go down'
  3296.     travelDir( actor ) = { return( actor.location.down ); }
  3297. ;
  3298. uVerb: travelVerb
  3299.     action( actor ) = { actor.travelTo( self.travelDir( actor )); }
  3300.     verb = 'u' 'up' 'go up'
  3301.     travelDir( actor ) = { return( actor.location.up ); }
  3302. ;
  3303.  
  3304. /*
  3305.  *   sysverb:  A system verb.  Verbs of this class are special verbs that
  3306.  *   can be executed without certain normal validations.  For example,
  3307.  *   a system verb can be executed in a dark room.  System verbs are
  3308.  *   for operations such as saving, restoring, and quitting, which are
  3309.  *   not really part of the game.
  3310.  */
  3311. class sysverb: deepverb
  3312.     issysverb = true
  3313. ;
  3314. quitVerb: sysverb
  3315.     verb = 'quit'
  3316.     action( actor ) =
  3317.     {
  3318.         local yesno;
  3319.  
  3320.         scoreRank();
  3321.         "\bDo you really want to quit? (YES or NO) > ";
  3322.         yesno := yorn();
  3323.         "\b";
  3324.         if ( yesno = 1 )
  3325.         {
  3326.             terminate();    // allow user good-bye message
  3327.         quit();
  3328.         }
  3329.         else
  3330.         {
  3331.             "Okay. ";
  3332.         }
  3333.     abort;
  3334.     }
  3335. ;
  3336. verboseVerb: sysverb
  3337.     verb = 'verbose'
  3338.     action( actor ) =
  3339.     {
  3340.         "Okay, now in VERBOSE mode.\n";
  3341.         global.verbose := true;
  3342.     Me.location.lookAround( true );
  3343.     abort;
  3344.     }
  3345. ;
  3346. terseVerb: sysverb
  3347.     verb = 'brief' 'terse'
  3348.     action( actor ) =
  3349.     {
  3350.         "Okay, now in TERSE mode.\n";
  3351.         global.verbose := nil;
  3352.     abort;
  3353.     }
  3354. ;
  3355. scoreVerb: sysverb
  3356.     verb = 'score' 'status'
  3357.     action( actor ) =
  3358.     {
  3359.         scoreRank();
  3360.     abort;
  3361.     }
  3362. ;
  3363. saveVerb: sysverb
  3364.     verb = 'save'
  3365.     sdesc = "save"
  3366.     doAction = 'Save'
  3367.     action( actor ) =
  3368.     {
  3369.         local savefile;
  3370.     
  3371.     savefile := askfile( 'File to save game in' );
  3372.     if ( savefile = nil or savefile = '' )
  3373.         "Failed. ";
  3374.     else if (save( savefile ))
  3375.         "Saved failed. ";
  3376.     else
  3377.         "Saved. ";
  3378.     abort;
  3379.     }
  3380. ;
  3381. restoreVerb: sysverb
  3382.     verb = 'restore'
  3383.     sdesc = "restore"
  3384.     doAction = 'Restore'
  3385.     action( actor ) =
  3386.     {
  3387.         local savefile;
  3388.     
  3389.     savefile := askfile( 'File to restore game from' );
  3390.     if ( savefile = nil or savefile = '' )
  3391.         "Failed. ";
  3392.     else if (restore( savefile ))
  3393.         "Restore failed. ";
  3394.     else
  3395.     {
  3396.         setscore( global.score, global.turnsofar );
  3397.         "Restored. ";
  3398.     }
  3399.     abort;
  3400.     }
  3401. ;
  3402. scriptVerb: sysverb
  3403.     verb = 'script'
  3404.     doAction = 'Script'
  3405.     action( actor ) =
  3406.     {
  3407.         local scriptfile;
  3408.     
  3409.     scriptfile := askfile( 'File to write transcript to' );
  3410.     if ( scriptfile = nil or scriptfile = '' )
  3411.         "Failed. ";
  3412.     else
  3413.     {
  3414.         logging( scriptfile );
  3415.         "Writing script file. ";
  3416.     }
  3417.     abort;
  3418.     }
  3419. ;
  3420. unscriptVerb: sysverb
  3421.     verb = 'unscript'
  3422.     action( actor ) =
  3423.     {
  3424.         logging( nil );
  3425.         "Script closed.\n";
  3426.         abort;
  3427.     }
  3428. ;
  3429. restartVerb: sysverb
  3430.     verb = 'restart'
  3431.     action( actor ) =
  3432.     {
  3433.         local yesno;
  3434.         while ( true )
  3435.         {
  3436.             "Are you sure you want to start over? (YES or NO) > ";
  3437.             yesno := yorn();
  3438.             if ( yesno = 1 )
  3439.             {
  3440.                 "\n";
  3441.         setscore( 0, 0 );
  3442.                 restart();
  3443.                 abort;
  3444.             }
  3445.             else if ( yesno = 0 )
  3446.             {
  3447.                 "\nOkay.\n";
  3448.                 abort;
  3449.             }
  3450.         }
  3451.     }
  3452. ;
  3453. versionVerb: sysverb
  3454.     verb = 'version'
  3455.     action( actor ) =
  3456.     {
  3457.         version.sdesc;
  3458.         abort;
  3459.     }
  3460. ;
  3461. debugVerb: sysverb
  3462.     verb = 'debug'
  3463.     action( actor ) =
  3464.     {
  3465.     if (debugTrace())
  3466.         "You can't think this game has any bugs left in it... ";
  3467.     abort;
  3468.     }
  3469. ;
  3470.  
  3471. undoVerb: sysverb
  3472.     verb = 'undo'
  3473.     action(actor) =
  3474.     {
  3475.     /* do TWO undo's - one for this 'undo', one for previous command */
  3476.     if (undo() and undo())
  3477.     {
  3478.         "(Undoing one command)\b";
  3479.         Me.location.lookAround(true);
  3480.         setscore(global.score, global.turnsofar);
  3481.     }
  3482.     else
  3483.         "No more undo information is available. ";
  3484.  
  3485.     abort;
  3486.     }
  3487. ;
  3488.  
  3489. /*
  3490.  *  Prep: object
  3491.  *
  3492.  *  A preposition.  The preposition property specifies the
  3493.  *  vocabulary word.
  3494. */
  3495. class Prep: object
  3496. ;
  3497.  
  3498. /*
  3499.  *   Various prepositions
  3500.  */
  3501. aboutPrep: Prep
  3502.     preposition = 'about'
  3503.     sdesc = "about"
  3504. ;
  3505. withPrep: Prep
  3506.     preposition = 'with'
  3507.     sdesc = "with"
  3508. ;
  3509. toPrep: Prep
  3510.     preposition = 'to'
  3511.     sdesc = "to"
  3512. ;
  3513. onPrep: Prep
  3514.     preposition = 'on' 'onto' 'downon' 'upon'
  3515.     sdesc = "on"
  3516. ;
  3517. inPrep: Prep
  3518.     preposition = 'in' 'into' 'downin'
  3519.     sdesc = "in"
  3520. ;
  3521. offPrep: Prep
  3522.     preposition = 'off' 'offof'
  3523.     sdesc = "off"
  3524. ;
  3525. outPrep: Prep
  3526.     preposition = 'out' 'outof'
  3527.     sdesc = "out"
  3528. ;
  3529. fromPrep: Prep
  3530.     preposition = 'from'
  3531.     sdesc = "from"
  3532. ;
  3533. betweenPrep: Prep
  3534.     preposition = 'between' 'inbetween'
  3535.     sdesc = "between"
  3536. ;
  3537. overPrep: Prep
  3538.     preposition = 'over'
  3539.     sdesc = "over"
  3540. ;
  3541. atPrep: Prep
  3542.     preposition = 'at'
  3543.     sdesc = "at"
  3544. ;
  3545. aroundPrep: Prep
  3546.     preposition = 'around'
  3547.     sdesc = "around"
  3548. ;
  3549. thruPrep: Prep
  3550.     preposition = 'through' 'thru'
  3551.     sdesc = "through"
  3552. ;
  3553. dirPrep: Prep
  3554.     preposition = 'north' 'south' 'east' 'west' 'up' 'down' 'northeast' 'ne'
  3555.                   'northwest' 'nw' 'southeast' 'se' 'southwest' 'sw'
  3556.     sdesc = "north"         // Shouldn't ever need this, but just in case
  3557. ;
  3558. underPrep: Prep
  3559.     preposition = 'under' 'beneath'
  3560.     sdesc = "under"
  3561. ;
  3562. behindPrep: Prep
  3563.     preposition = 'behind'
  3564.     sdesc = "behind"
  3565. ;
  3566.  
  3567. /*
  3568.  *   articles:  the "built-in" articles.  "The," "a," and "an" are
  3569.  *   defined.
  3570.  */
  3571. articles: object
  3572.     article = 'the' 'a' 'an'
  3573. ;
  3574.